Skip to content

Commit

Permalink
Merge pull request #409 from ExCiteS/dj111_upgrade_pt3
Browse files Browse the repository at this point in the history
Django 1.11 upgrade
  • Loading branch information
JamesBradbury authored Sep 19, 2018
2 parents 8875500 + 55fbafd commit 21ad21e
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ addons:
- postgresql-9.4-postgis-2.3

env:
- DJANGO='>=1.8.19,<1.9'
- DJANGO='>=1.8.19,<1.12'

virtualenv:
system_site_packages: true
Expand Down
16 changes: 8 additions & 8 deletions geokey/categories/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_only_fields(self):
LookupFieldFactory(category=category)
MultipleLookupFieldFactory(category=category)

all_fields = category.fields.all()
all_fields = category.fields.all().select_subclasses()

type_names = [
'Text',
Expand All @@ -47,7 +47,7 @@ def test_only_fields(self):

date_fields = filter_fields.only_fields(
all_fields,
(', ').join(type_names)
', '.join(type_names)
)
self.assertEqual(len(date_fields), len(type_names))
for field in date_fields:
Expand All @@ -66,7 +66,7 @@ def test_except_fields(self):
LookupFieldFactory(category=category)
MultipleLookupFieldFactory(category=category)

all_fields = category.fields.all()
all_fields = category.fields.all().select_subclasses()

type_names = [
'Text',
Expand All @@ -79,13 +79,13 @@ def test_except_fields(self):
]

for type_name in type_names:
date_fields = filter_fields.except_fields(all_fields, type_name)
self.assertEqual(len(date_fields), len(type_names) - 1)
for field in date_fields:
remaining_fields = filter_fields.except_fields(all_fields, type_name)
self.assertEqual(len(remaining_fields), len(type_names) - 1)
for field in remaining_fields:
self.assertNotEqual(field.type_name, type_name)

date_fields = filter_fields.except_fields(
all_fields,
(', ').join(type_names)
fields=all_fields,
type_names=', '.join(type_names)
)
self.assertEqual(len(date_fields), 0)
2 changes: 1 addition & 1 deletion geokey/contributions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def update_count(self):
def create_search_index(self):
search_index = []

for field in self.category.fields.all():
for field in self.category.fields.all().select_subclasses():
value = None
if self.properties and field.key in self.properties.keys():
if field.fieldtype == 'TextField':
Expand Down
2 changes: 1 addition & 1 deletion geokey/contributions/tests/comments/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_create_reviewcomment_with_admin(self):
self.assertEqual(ref.status, 'review')

def test_create_reviewcomment_to_empty_obs_with_admin(self):
self.contribution.properties = None
self.contribution.properties = {}
self.contribution.save()

url = reverse('api:project_comments', kwargs={
Expand Down
8 changes: 4 additions & 4 deletions geokey/contributions/tests/observations/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_update_display_field_empty_properties(self):
'project': category.project,
'category': category,
'display_field': None,
'properties': None
'properties': {}
})

observation.update_display_field()
Expand All @@ -226,7 +226,7 @@ def test_update_display_field_no_display_field(self):
'project': category.project,
'category': category,
'display_field': None,
'properties': None
'properties': {}
})

observation.update_display_field()
Expand Down Expand Up @@ -275,7 +275,7 @@ def test_update_expiry_field_empty_properties(self):
'project': category.project,
'category': category,
'expiry_field': None,
'properties': None
'properties': {}
})

observation.update_expiry_field()
Expand All @@ -295,7 +295,7 @@ def test_update_expiry_field_no_expiry_field(self):
'project': category.project,
'category': category,
'expiry_field': None,
'properties': None
'properties': {}
})

observation.update_expiry_field()
Expand Down
2 changes: 1 addition & 1 deletion geokey/contributions/tests/observations/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_approve_pending_with_admin(self):
)

def test_approve_pending_with_admin_empty_properties(self):
self.observation.properties = None
self.observation.properties = {}
self.observation.status = 'pending'
self.observation.save()

Expand Down
11 changes: 6 additions & 5 deletions geokey/users/tests/test_admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from django.contrib.sites.shortcuts import get_current_site
from django.contrib.messages import get_messages, WARNING
from django.contrib.messages.storage.fallback import FallbackStorage
from django.utils import timezone

from nose.tools import raises
from oauth2_provider.models import AccessToken
Expand Down Expand Up @@ -1547,9 +1548,9 @@ def setUp(self):
self.user_no_contributions = UserFactory.create(**{'display_name': 'delete_test_no_contribs_user'})
self.user_with_contributions = UserFactory.create(**{'display_name': 'delete_test_contribs_user',
'email': '[email protected]',
'date_joined': '2016-12-15 14:22:24.632764',
'last_login': '2018-01-01 10:00:00.000001'})
token_expiry = datetime.now() + timedelta(hours=1)
'date_joined': '2016-12-15 14:22:24.632764Z',
'last_login': '2018-01-01 10:00:00.000001Z'})
token_expiry = timezone.now() + timedelta(hours=1)
app = ApplicationFactory.create()
self.access_token_contribs = AccessToken.objects.get_or_create(**{'user': self.user_with_contributions,
'expires': token_expiry,
Expand Down Expand Up @@ -1628,9 +1629,9 @@ def test_user_details_removed(self):
result_user = User.objects.get_or_create(id=user_id)[0]
self.assertEqual(result_user.display_name[:12], 'Deleted user')
self.assertEqual(result_user.email[-17:], 'deleteduser.email')
self.assertEqual(result_user.date_joined.strftime('%Y-%m-%d %H:%M:%S.%f'), '2018-04-01 11:11:11.111111')
self.assertEqual(result_user.date_joined.strftime('%Y-%m-%d %H:%M:%S'), '2018-04-01 11:11:11')
self.assertAlmostEqual(datetime.strftime(result_user.last_login, '%Y-%m-%d %H:%M'),
datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M'))
datetime.strftime(timezone.now(), '%Y-%m-%d %H:%M'))
self.assertFalse(result_user.is_active, msg="User should no longer be active.")

access_tokens = AccessToken.objects.filter(user=result_user)
Expand Down
7 changes: 4 additions & 3 deletions geokey/users/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Views for users."""
from datetime import datetime
from json import loads as json_loads

from dateutil.tz import tzoffset
from django.contrib.auth import logout
from django.utils import timezone
from django.views.generic import TemplateView, CreateView
from django.shortcuts import redirect
from django.core.exceptions import ValidationError
Expand Down Expand Up @@ -626,8 +627,8 @@ def post(self, request):
random_password = ''.join(random.choice(ascii_lowercase) for _ in range(15))
user.email = random_numbers + '@' + 'deleteduser.email'
user.display_name = 'Deleted user ' + random_numbers
user.date_joined = datetime.strptime('2018-04-01 11:11:11.111111', '%Y-%m-%d %H:%M:%S.%f')
user.last_login = datetime.now()
user.date_joined = datetime(2018, 4, 1, 11, 11, 11, tzinfo=tzoffset(None, 0))
user.last_login = timezone.now()
logout(request)
user.is_active = False
user.reset_password(password=random_password)
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Django>=1.8.19,<1.9
factory-boy==2.10.0
factory-boy==2.11.1
django-debug-toolbar==1.7
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Django>=1.8.19,<1.9
Django>=1.8.19,<1.12
django-aggregate-if==0.5
django-allauth==0.33.0
django-braces==1.11.0
django-crontab==0.7.1
django-hstore==1.4.2
django-model-utils==2.6.1
django-model-utils==3.1.2
django-oauth-toolkit==0.12.0
django-pgjson==0.3.1
django-simple-history==1.8.2
Expand Down

0 comments on commit 21ad21e

Please sign in to comment.