-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field changes to the territorial entity. #127
Changes from 9 commits
78e5e0b
728a236
c54418e
9097cc4
0a37bfb
0c26622
88e5fc7
b3ae534
d0fb730
1a1d03e
1635881
194202d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Generated by Django 2.2.1 on 2019-05-11 15:57 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0010_auto_20190430_0334'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='historicalterritorialentity', | ||
name='dissolution_date', | ||
field=models.DecimalField(decimal_places=1, default=0, max_digits=10), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='historicalterritorialentity', | ||
name='inception_date', | ||
field=models.DecimalField(decimal_places=1, default=0, max_digits=10), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='territorialentity', | ||
name='dissolution_date', | ||
field=models.DecimalField(decimal_places=1, default=0, max_digits=10), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='territorialentity', | ||
name='inception_date', | ||
field=models.DecimalField(decimal_places=1, default=0, max_digits=10), | ||
preserve_default=False, | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 2.2.1 on 2019-05-11 18:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0011_auto_20190511_1557'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='historicalterritorialentity', | ||
name='label', | ||
field=models.TextField(default='default', max_length=90), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='territorialentity', | ||
name='label', | ||
field=models.TextField(default='default', max_length=90), | ||
preserve_default=False, | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 2.2.1 on 2019-06-08 05:03 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0012_auto_20190511_1812'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='historicalterritorialentity', | ||
name='stv_count', | ||
field=models.IntegerField(blank=True, default=0, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='territorialentity', | ||
name='predecessor', | ||
field=models.ManyToManyField(blank=True, to='api.TerritorialEntity'), | ||
), | ||
migrations.AddField( | ||
model_name='territorialentity', | ||
name='stv_count', | ||
field=models.IntegerField(blank=True, default=0, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalterritorialentity', | ||
name='dissolution_date', | ||
field=models.DecimalField(blank=True, decimal_places=1, max_digits=10, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='territorialentity', | ||
name='dissolution_date', | ||
field=models.DecimalField(blank=True, decimal_places=1, max_digits=10, null=True), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 2.2.1 on 2019-06-13 06:22 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0013_auto_20190608_0503'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='historicalterritorialentity', | ||
name='stv_count', | ||
), | ||
migrations.RemoveField( | ||
model_name='territorialentity', | ||
name='stv_count', | ||
), | ||
migrations.AlterField( | ||
model_name='historicalterritorialentity', | ||
name='inception_date', | ||
field=models.DecimalField(blank=True, decimal_places=1, max_digits=10, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='territorialentity', | ||
name='inception_date', | ||
field=models.DecimalField(blank=True, decimal_places=1, max_digits=10, null=True), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -33,8 +33,18 @@ class TerritorialEntity(models.Model): | |||||||||||||
""" | ||||||||||||||
|
||||||||||||||
wikidata_id = models.PositiveIntegerField() # Excluding the Q | ||||||||||||||
label = models.TextField(max_length=90) | ||||||||||||||
color = ColorField() | ||||||||||||||
admin_level = models.PositiveIntegerField() | ||||||||||||||
inception_date = models.DecimalField( | ||||||||||||||
decimal_places=1, max_digits=10, blank=True, null=True | ||||||||||||||
) | ||||||||||||||
dissolution_date = models.DecimalField( | ||||||||||||||
decimal_places=1, max_digits=10, blank=True, null=True | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure that we should do this strict validation on the inception date? Especially when you are validating it for not null Lines 55 to 60 in 88e5fc7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One more question, why inception and dissolution date are returned as a string via API request? {
"id":2,
"stvs":[],
"stv_count":0,
"wikidata_id":30,
"label":"USA2",
"color":"10",
"admin_level":2,
"inception_date":"0.0",
"dissolution_date":null,
"predecessor":[],
"relations":[]
} I've noticed that we have one more reserved SQL word as a column - The response after adding an STV {
"id": 1,
"stvs": [ // This is an array of all stvs
{
"id": 1,
"start_date": "1.0",
"end_date": "0.0",
"references": [
"qwe",
"qwee"
],
"visual_center": {
"type": "Point",
"coordinates": [
-71.060316,
48.432044
]
},
"entity": 1,
"related_events": []
}
],
"stv_count": 1, // this is a new count field
"wikidata_id": 30,
"label": "USA",
"color": "10",
"admin_level": 2,
"inception_date": "0.0",
"dissolution_date": "0.0",
"predecessor": [],
"relations": []
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking thinking the dates as a user input but of course since we have gaps in wikidata both date fields should have less restriction. I guess they should be nullable? I need to convert the dates using the library in the viewset I think. Will take care of it. What should references be changed as. Citations comes to mind. |
||||||||||||||
) | ||||||||||||||
|
||||||||||||||
predecessor = models.ManyToManyField("self", blank=True, symmetrical=False) | ||||||||||||||
|
||||||||||||||
relations = models.ManyToManyField( | ||||||||||||||
"self", | ||||||||||||||
blank=True, | ||||||||||||||
|
@@ -44,6 +54,15 @@ class TerritorialEntity(models.Model): | |||||||||||||
) | ||||||||||||||
history = HistoricalRecords() | ||||||||||||||
|
||||||||||||||
def clean(self, *args, **kwargs): # pylint: disable=W0221 | ||||||||||||||
if not self.inception_date is None and not self.dissolution_date is None: | ||||||||||||||
if self.inception_date > self.dissolution_date: | ||||||||||||||
raise ValidationError( | ||||||||||||||
"Inception date cannot be later than dissolution date" | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
super(TerritorialEntity, self).clean(*args, **kwargs) | ||||||||||||||
|
||||||||||||||
def get_children(self): | ||||||||||||||
""" | ||||||||||||||
Returns relations in which this nation is a parent | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .model_tests import * | ||
from .api_tests import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a nullable PointField similar to
visual_center
, and updated as a post create hookThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, on second thought we should probably keep this field for #21. We will still need the PointField though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have Point Field for the visual center in STV's table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, my comment was before the Slack post. Originally I was thinking a field here could correspond to P625 for a wikdiata entity but it doesn't seem that property does us much good in any situation.