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

Upgrade to Django 2.2 #1770

Merged
merged 3 commits into from
Jan 27, 2020
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sudo: required
dist: trusty
dist: xenial
language: python
addons:
postgresql: 9.6
Expand Down Expand Up @@ -35,8 +35,8 @@ before_install:
- export DEBIAN_FRONTEND=noninteractive;
- sudo rm -f /etc/apt/sources.list.d/mongodb-3.4.list
- sudo -E apt-get -y update
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install postgresql-9.6-postgis-2.3
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install openjdk-8-jre-headless
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends install postgresql-9.6-postgis-2.4
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends install openjdk-8-jre-headless
- ./script/database/install_postgis onadata_test postgres 127.0.0.1

install:
Expand Down
11 changes: 11 additions & 0 deletions onadata/apps/api/tests/views/test_user_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def test_manager_can_update_xform(self):

self.assertFalse(self.xform.shared)

# Remove key:value pairs where the value is None.
# More info: https://code.djangoproject.com/ticket/30024
data.pop('enketo_preview_url')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is related to this issue here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. Do we add the link - https://code.djangoproject.com/ticket/30024 - as a comment just above the <obj>.pop('<key>') so that in future, we can easily know why we had to do this?

Copy link
Contributor Author

@DavisRayM DavisRayM Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll add a link. In case someone works on the code later on.

data.pop('last_submission_time')

request = self.factory.put('/', data=data, **self.extra)
response = view(request, pk=self.xform.id)
self.assertEqual(response.status_code, 404)
Expand Down Expand Up @@ -306,6 +311,12 @@ def test_owner_role(self):
context={'request': request})
data = json.loads(JSONRenderer().render(xfs.data))
data.update({'public': True, 'description': "Some description"})

# Remove key:value pairs where the value is None.
# More info: https://code.djangoproject.com/ticket/30024
data.pop('enketo_preview_url')
data.pop('last_submission_time')

request = self.factory.put('/', data=data, **self.extra)
response = view(request, pk=formid)
self.assertEqual(response.status_code, 200)
Expand Down
4 changes: 2 additions & 2 deletions onadata/apps/api/tests/viewsets/test_connect_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def test_reset_user_password(self):
self.assertEqual(response.status_code, 400)

data['uid'] = urlsafe_base64_encode(
force_bytes(self.user.pk)).decode('utf-8')
force_bytes(self.user.pk))
# with uid, should be successful
request = self.factory.post('/', data=data)
response = self.view(request)
Expand All @@ -314,7 +314,7 @@ def test_reset_user_password_with_updated_user_email(self):
self.user.save()
new_password = "bobbob1"
uid = urlsafe_base64_encode(
force_bytes(self.user.pk)).decode('utf-8')
force_bytes(self.user.pk))
mhv = default_token_generator
token = mhv.make_token(self.user)
data = {'token': token, 'new_password': new_password,
Expand Down
2 changes: 1 addition & 1 deletion onadata/apps/api/tests/viewsets/test_open_data_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_create_open_data_object_with_invalid_fields(self):
'name': self.xform.id_string
}

data.update({'object_id': None})
data.update({'object_id': 'sup'})
request = self.factory.post('/', data=data, **self.extra)
response = self.view(request)
self.assertEqual(response.status_code, 400)
Expand Down
5 changes: 2 additions & 3 deletions onadata/libs/serializers/password_reset_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ def get_password_reset_email(user, reset_url,
"""Creates the subject and email body for password reset email."""
result = urlparse(reset_url)
site_name = domain = result.hostname
encoded_username = urlsafe_base64_encode(
b(user.username.encode('utf-8'))).decode('utf-8')
encoded_username = urlsafe_base64_encode(b(user.username.encode('utf-8')))
Copy link
Contributor Author

@DavisRayM DavisRayM Jan 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this because urlsafe_base64_encode now returns a string instead of a bytestring.

c = {
'email': user.email,
'domain': domain,
'path': result.path,
'site_name': site_name,
'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode('utf-8'),
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'username': user.username,
'encoded_username': encoded_username,
'token': token_generator.make_token(user),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def test_get_password_reset_email(self):

self.assertIn(
urlsafe_base64_encode(
bytes(self.user.username.encode('utf-8'))).decode('utf-8'),
self.user.username.encode('utf-8')),
email,
"Username is included in reset email.")
self.assertIn(
'uid={}'.format(urlsafe_base64_encode(
force_bytes(self.user.pk)).decode('utf-8')),
force_bytes(self.user.pk))),
email,
"Uid is included in email.")
5 changes: 2 additions & 3 deletions requirements/base.pip
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
alabaster==0.7.12 # via sphinx
amqp==2.4.2 # via kombu
argparse==1.4.0 # via unittest2
asn1crypto==1.0.1 # via cryptography
attrs==19.1.0 # via jsonschema
babel==2.6.0 # via sphinx
billiard==3.5.0.5 # via celery
Expand Down Expand Up @@ -42,7 +41,7 @@ django-render-block==0.6 # via django-templated-email
django-reversion==3.0.3
django-taggit==1.1.0
django-templated-email==2.3.0
django==2.1.7 # via django-cors-headers, django-debug-toolbar, django-filter, django-oauth-toolkit, django-query-builder, django-render-block, django-reversion, django-taggit, djangorestframework-jsonapi, jsonfield
django==2.2.9 # via django-cors-headers, django-debug-toolbar, django-filter, django-oauth-toolkit, django-query-builder, django-render-block, django-reversion, django-taggit, djangorestframework-jsonapi, jsonfield
djangorestframework-csv==2.1.0
djangorestframework-gis==0.14
djangorestframework-jsonapi==2.7.0
Expand Down Expand Up @@ -123,7 +122,7 @@ sphinxcontrib-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.2 # via sphinx
sphinxcontrib-serializinghtml==1.1.3 # via sphinx
sqlalchemy==1.3.3 # via tabulator
sqlparse==0.3.0 # via django-debug-toolbar
sqlparse==0.3.0 # via django, django-debug-toolbar
tableschema==1.4.1 # via datapackage
tabulator==1.20.0 # via datapackage, tableschema
traceback2==1.4.0 # via unittest2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
packages=find_packages(exclude=['docs', 'tests']),
install_requires=[
"Django>=2",
"Django>=2.2,<2.3",
"django-guardian",
"django-registration-redux",
"django-templated-email",
Expand Down