Skip to content
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

Add support for Django 2.0 #8

Merged
merged 3 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Changes we're making en route to version 2.0. When we cut a release, this
section will form the changelog for v2.0.

- Add support for Django 2.0 ([#8](https://github.com/azavea/grout/pull/8))
- Removed external `djsonb` dependency and moved its lookup logic into
Grout core ([#7](https://github.com/azavea/grout/pull/7)
- Removed extraneous location fields from the `Record` data model (
Expand Down
2 changes: 1 addition & 1 deletion grout/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='record',
name='schema_id',
field=models.ForeignKey(to='grout.RecordSchema'),
field=models.ForeignKey(to='grout.RecordSchema', on_delete=models.CASCADE),
),
migrations.AlterUniqueTogether(
name='itemschema',
Expand Down
2 changes: 1 addition & 1 deletion grout/migrations/0006_auto_20150424_1857.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='boundarypolygon',
name='boundary',
field=models.ForeignKey(related_name='polygons', to='grout.Boundary', null=True),
field=models.ForeignKey(related_name='polygons', to='grout.Boundary', null=True, on_delete=models.CASCADE),
),
]
4 changes: 2 additions & 2 deletions grout/migrations/0007_auto_20150427_2114.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='itemschema',
name='next_version',
field=models.OneToOneField(related_name='previous_version', null=True, to='grout.ItemSchema'),
field=models.OneToOneField(related_name='previous_version', null=True, to='grout.ItemSchema', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='recordschema',
name='next_version',
field=models.OneToOneField(related_name='previous_version', null=True, to='grout.RecordSchema'),
field=models.OneToOneField(related_name='previous_version', null=True, to='grout.RecordSchema', on_delete=models.CASCADE),
),
]
4 changes: 2 additions & 2 deletions grout/migrations/0009_auto_20150429_1627.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='itemschema',
name='next_version',
field=models.OneToOneField(related_name='previous_version', null=True, editable=False, to='grout.ItemSchema'),
field=models.OneToOneField(related_name='previous_version', null=True, editable=False, to='grout.ItemSchema', on_delete=models.CASCADE),
),
migrations.AlterField(
model_name='recordschema',
name='next_version',
field=models.OneToOneField(related_name='previous_version', null=True, editable=False, to='grout.RecordSchema'),
field=models.OneToOneField(related_name='previous_version', null=True, editable=False, to='grout.RecordSchema', on_delete=models.CASCADE),
),
]
2 changes: 1 addition & 1 deletion grout/migrations/0011_auto_20150505_1941.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='recordschema',
name='record_type',
field=models.ForeignKey(related_name='schemas', to='grout.RecordType'),
field=models.ForeignKey(related_name='schemas', to='grout.RecordType', on_delete=models.CASCADE),
),
migrations.AlterUniqueTogether(
name='recordschema',
Expand Down
13 changes: 9 additions & 4 deletions grout/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SchemaModel(GroutModel):
version = models.PositiveIntegerField()
schema = JSONField()
next_version = models.OneToOneField('self', related_name='previous_version', null=True,
editable=False)
editable=False, on_delete=models.CASCADE)

class Meta(object):
abstract = True
Expand Down Expand Up @@ -60,7 +60,7 @@ class Record(GroutModel):
geom = models.PointField(srid=settings.GROUT['SRID'])
location_text = models.CharField(max_length=200, null=True, blank=True)

schema = models.ForeignKey('RecordSchema')
schema = models.ForeignKey('RecordSchema', on_delete=models.CASCADE)
data = JSONField()

archived = models.BooleanField(default=False)
Expand All @@ -83,7 +83,9 @@ def get_current_schema(self):

class RecordSchema(SchemaModel):
"""Schemas for spatiotemporal records"""
record_type = models.ForeignKey('RecordType', related_name='schemas')
record_type = models.ForeignKey('RecordType',
related_name='schemas',
on_delete=models.CASCADE)

class Meta(object):
unique_together = (('record_type', 'version'),)
Expand Down Expand Up @@ -161,6 +163,9 @@ def load_shapefile(self):
class BoundaryPolygon(GroutModel):
""" Individual boundaries and associated data for each geom in a BoundaryUpload """

boundary = models.ForeignKey('Boundary', related_name='polygons', null=True)
boundary = models.ForeignKey('Boundary',
related_name='polygons',
null=True,
on_delete=models.CASCADE)
data = JSONField()
geom = models.MultiPolygonField(srid=settings.GROUT['SRID'])
2 changes: 1 addition & 1 deletion grout/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
router.register('recordtypes', views.RecordTypeViewSet)

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
url(r'^api/', include(router.urls)),
]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def readme():
packages=find_packages(exclude=['tests']),
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
install_requires=[
'Django ~=1.11',
'Django >=1.11, <=2.1',
'djangorestframework >=3.8.0',
'djangorestframework-gis >=0.8.1',
'django-filter >=1.1.0,<2.0.0',
Expand Down
6 changes: 5 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import json

from django.core.urlresolvers import reverse
import django
from django.contrib.gis.geos import Polygon, LinearRing, MultiPolygon

from rest_framework import status
Expand All @@ -10,6 +10,10 @@
from grout.models import (Boundary, BoundaryPolygon,
RecordSchema, RecordType)

if django.VERSION < (2, 0):
from django.core.urlresolvers import reverse
else:
from django.urls import reverse

class RecordSchemaViewTestCase(GroutAPITestCase):

Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[tox]
envlist =
{py27,py34,py35,py36}-django111,
{py34,py35,py36}-django20,

[testenv]
deps =
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
mock

commands = python run_tests.py
Expand Down