Skip to content

Commit

Permalink
Try #127:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] committed Jun 26, 2019
2 parents 48b8f12 + 1a1d03e commit 44f763f
Show file tree
Hide file tree
Showing 13 changed files with 1,250 additions and 332 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN set -ex \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
gdal-dev \
geos-dev \
proj4-dev \
proj-dev \
&& apk add --no-cache --virtual .build-deps \
gcc \
libc-dev \
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ exec_testk: ## Executes django tests in a running container, keeping the databas

lint: ## Lints python files to pass CI
docker-compose exec web black . --exclude /migrations/
docker-compose exec web pylint ./api/

docker-compose exec web pylint --ignore=tests ./api/
docker-compose exec web pylint --rcfile=api/tests/pylintrc ./api/tests

bash: ## Create shell in web container
docker-compose exec web sh

Expand Down
37 changes: 37 additions & 0 deletions project/api/migrations/0011_auto_20190511_1557.py
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,
),
]
25 changes: 25 additions & 0 deletions project/api/migrations/0012_auto_20190511_1812.py
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,
),
]
38 changes: 38 additions & 0 deletions project/api/migrations/0013_auto_20190608_0503.py
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),
),
]
31 changes: 31 additions & 0 deletions project/api/migrations/0014_auto_20190613_0622.py
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),
),
]
19 changes: 19 additions & 0 deletions project/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

predecessor = models.ManyToManyField("self", blank=True, symmetrical=False)

relations = models.ManyToManyField(
"self",
blank=True,
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions project/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TerritorialEntitySerializer(ModelSerializer):
"""

stvs = SpacetimeVolumeSerializerNoTerritory(many=True, read_only=True)
stv_count = IntegerField(read_only=True)

class Meta:
model = TerritorialEntity
Expand Down
3 changes: 3 additions & 0 deletions project/api/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Module that contains tests"""
from .model_tests import *
from .api_tests import *
Loading

0 comments on commit 44f763f

Please sign in to comment.