From d4d1d9077a50933f3d8ac9323a16570e99e7e97c Mon Sep 17 00:00:00 2001 From: JamesBradbury Date: Wed, 19 Sep 2018 18:12:31 +0100 Subject: [PATCH 01/11] Updated version of lxml Test with latest GeoKey and Django 1.11 --- .travis.yml | 10 ++-------- setup.py | 2 +- travis_ci/requirements.txt | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01234ab..21f88e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,14 +14,8 @@ addons: - postgresql-9.4-postgis-2.3 env: - - GEOKEY='>=1.0,<1.1' DJANGO='>=1.8,<1.9' - - GEOKEY='>=1.0,<1.1' DJANGO='>=1.9,<1.10' - - GEOKEY='>=1.1,<1.2' DJANGO='>=1.8,<1.9' - - GEOKEY='>=1.1,<1.2' DJANGO='>=1.9,<1.10' - - GEOKEY='>=1.2,<1.3' DJANGO='>=1.8,<1.9' - - GEOKEY='>=1.2,<1.3' DJANGO='>=1.9,<1.10' - - GEOKEY='' DJANGO='>=1.8,<1.9' - - GEOKEY='' DJANGO='>=1.9,<1.10' + - GEOKEY='>=1.6,<1.7' DJANGO='>=1.9,<1.10' + - GEOKEY='>=1.6,<1.7' DJANGO='>=1.11,<1.12' virtualenv: system_site_packages: true diff --git a/setup.py b/setup.py index 4be6c62..5fff932 100644 --- a/setup.py +++ b/setup.py @@ -19,5 +19,5 @@ license='MIT', packages=find_packages(exclude=['*.tests', '*.tests.*', 'tests.*']), include_package_data=True, - install_requires=['lxml==3.3.5'], + install_requires=['lxml==4.2.5'], ) diff --git a/travis_ci/requirements.txt b/travis_ci/requirements.txt index d9a8e57..300dd01 100644 --- a/travis_ci/requirements.txt +++ b/travis_ci/requirements.txt @@ -1,3 +1,4 @@ django-debug-toolbar factory-boy coveralls +lxml==4.2.5 From 5c9c4fd251b70fabc578083b5a27db9aaaafa1f4 Mon Sep 17 00:00:00 2001 From: JamesBradbury Date: Thu, 1 Nov 2018 17:49:46 +0000 Subject: [PATCH 02/11] Improve travis CI settings --- travis_ci/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/travis_ci/settings.py b/travis_ci/settings.py index 6019ca8..934c921 100644 --- a/travis_ci/settings.py +++ b/travis_ci/settings.py @@ -8,6 +8,7 @@ SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxx' +# Database settings DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', @@ -19,6 +20,7 @@ } } + INSTALLED_APPS += ( 'geokey_epicollect', ) @@ -29,3 +31,5 @@ MEDIA_URL = '/assets/' WSGI_APPLICATION = 'wsgi.application' + +ALLOWED_HOSTS = ['localhost'] From 0aec148fb2fa0723eaf76847406e9209f5c19e0b Mon Sep 17 00:00:00 2001 From: JamesBradbury Date: Fri, 2 Nov 2018 16:39:20 +0000 Subject: [PATCH 03/11] Python 3 import compatibility fixes. --- geokey_epicollect/urls.py | 2 +- geokey_epicollect/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/geokey_epicollect/urls.py b/geokey_epicollect/urls.py index f428aa4..199206f 100644 --- a/geokey_epicollect/urls.py +++ b/geokey_epicollect/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import url -from views import ( +from geokey_epicollect.views import ( IndexPage, EpiCollectProject, EpiCollectUploadView, EpiCollectDownloadView ) diff --git a/geokey_epicollect/views.py b/geokey_epicollect/views.py index f0a0a0f..6f49e8c 100644 --- a/geokey_epicollect/views.py +++ b/geokey_epicollect/views.py @@ -16,7 +16,7 @@ from geokey.contributions.models import ImageFile, MediaFile from geokey.users.models import User -from serializer import ProjectFormSerializer, DataSerializer +from geokey_epicollect.serializer import ProjectFormSerializer, DataSerializer from .models import ( EpiCollectMedia, EpiCollectProject as EpiCollectProjectModel From 48b7df4515f7e00283260f1e13b1e944242bf226 Mon Sep 17 00:00:00 2001 From: JamesBradbury Date: Fri, 2 Nov 2018 16:40:29 +0000 Subject: [PATCH 04/11] Allow newer versions of lxml. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4be6c62..5b05cb7 100644 --- a/setup.py +++ b/setup.py @@ -19,5 +19,5 @@ license='MIT', packages=find_packages(exclude=['*.tests', '*.tests.*', 'tests.*']), include_package_data=True, - install_requires=['lxml==3.3.5'], + install_requires=['lxml>=3.3.5'], ) From 61c00f7c01b54d1fc72504e42acc7ffb53af2ff8 Mon Sep 17 00:00:00 2001 From: JamesBradbury Date: Fri, 2 Nov 2018 16:54:09 +0000 Subject: [PATCH 05/11] 2to3 auto-update. --- geokey_epicollect/migrations/0001_initial.py | 2 +- geokey_epicollect/migrations/0002_epicollectmedia.py | 2 +- geokey_epicollect/serializer.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/geokey_epicollect/migrations/0001_initial.py b/geokey_epicollect/migrations/0001_initial.py index 4a915e3..73d3b49 100644 --- a/geokey_epicollect/migrations/0001_initial.py +++ b/geokey_epicollect/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/geokey_epicollect/migrations/0002_epicollectmedia.py b/geokey_epicollect/migrations/0002_epicollectmedia.py index 30ba448..f30c892 100644 --- a/geokey_epicollect/migrations/0002_epicollectmedia.py +++ b/geokey_epicollect/migrations/0002_epicollectmedia.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/geokey_epicollect/serializer.py b/geokey_epicollect/serializer.py index 47c8c00..c3a7b24 100644 --- a/geokey_epicollect/serializer.py +++ b/geokey_epicollect/serializer.py @@ -301,7 +301,7 @@ def serialize_entry_to_xml(self, observation): uploaded.text = observation.created_at.strftime('%Y-%m-%d %H:%M:%S') entry.append(uploaded) - for key, value in observation.properties.iteritems(): + for key, value in observation.properties.items(): tag_name = key.replace('-', '_') if key not in self.static_fields: tag_name = tag_name + '_' + str(observation.category.id) @@ -340,7 +340,7 @@ def serialize_entry_to_tsv(self, observation): line = line + 'created\t' + str(calendar.timegm(observation.created_at.utctimetuple())) + '\t' line = line + 'uploaded\t' + observation.created_at.strftime('%Y-%m-%d %H:%M:%S') + '\t' - for key, value in observation.properties.iteritems(): + for key, value in observation.properties.items(): tag_name = key.replace('-', '_') if key not in self.static_fields: tag_name = tag_name + '_' + str(observation.category.id) From a012b87c91ba5f8e5ca4a25d8f8a5d591f9ba3ae Mon Sep 17 00:00:00 2001 From: JamesBradbury Date: Fri, 2 Nov 2018 17:00:42 +0000 Subject: [PATCH 06/11] Decode response content for py3 testing. --- geokey_epicollect/tests/test_views.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/geokey_epicollect/tests/test_views.py b/geokey_epicollect/tests/test_views.py index c6a8570..5097903 100644 --- a/geokey_epicollect/tests/test_views.py +++ b/geokey_epicollect/tests/test_views.py @@ -144,7 +144,7 @@ def test_get_not_existing_project(self): response = view(request, project_id=45454544) self.assertEqual(response.status_code, 403) self.assertIn( - response.content, + response.content.decode('utf-8'), 'The project must enabled for EpiCollect.' ) @@ -182,7 +182,7 @@ def test_upload_data(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '1') + self.assertEqual(response.content.decode('utf-8'), '1') def test_upload_data_with_media(self): project = ProjectFactory.create( @@ -214,7 +214,7 @@ def test_upload_data_with_media(self): response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) self.assertEqual(EpiCollectMedia.objects.count(), 2) - self.assertEqual(response.content, '1') + self.assertEqual(response.content.decode('utf-8'), '1') def test_upload_data_without_location(self): project = ProjectFactory.create( @@ -243,7 +243,7 @@ def test_upload_data_without_location(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '0') + self.assertEqual(response.content.decode('utf-8'), '0') def test_upload_category_does_not_exist(self): project = ProjectFactory.create( @@ -267,7 +267,7 @@ def test_upload_category_does_not_exist(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '0') + self.assertEqual(response.content.decode('utf-8'), '0') def test_upload_category_is_null(self): project = ProjectFactory.create( @@ -291,7 +291,7 @@ def test_upload_category_is_null(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '0') + self.assertEqual(response.content.decode('utf-8'), '0') def test_upload_checkboxes(self): project = ProjectFactory.create( @@ -325,7 +325,7 @@ def test_upload_checkboxes(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '1') + self.assertEqual(response.content.decode('utf-8'), '1') def test_upload_data_to_private_project(self): project = ProjectFactory.create() @@ -352,7 +352,7 @@ def test_upload_data_to_private_project(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '0') + self.assertEqual(response.content.decode('utf-8'), '0') def test_upload_image(self): image = get_image() @@ -374,7 +374,7 @@ def test_upload_image(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '1') + self.assertEqual(response.content.decode('utf-8'), '1') def test_upload_image_with_fullimage_flag(self): image = get_image() @@ -396,7 +396,7 @@ def test_upload_image_with_fullimage_flag(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '1') + self.assertEqual(response.content.decode('utf-8'), '1') def test_upload_image_with_wrong_file_name(self): image = get_image() @@ -418,7 +418,7 @@ def test_upload_image_with_wrong_file_name(self): view = EpiCollectUploadView.as_view() response = view(request, project_id=project.id) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, '0') + self.assertEqual(response.content.decode('utf-8'), '0') class DownloadDataTest(APITestCase): From c228a0e9d2b5e16ccf7fe70e758fa52cf665d57e Mon Sep 17 00:00:00 2001 From: Julius Osokinas Date: Sat, 3 Nov 2018 15:49:27 +0000 Subject: [PATCH 07/11] Remove unecessary comment - it's straightforward what is does --- travis_ci/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/travis_ci/settings.py b/travis_ci/settings.py index cb11ddd..eaf059b 100644 --- a/travis_ci/settings.py +++ b/travis_ci/settings.py @@ -8,7 +8,6 @@ SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxx' -# Database settings DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', From c2ceedce363c69d26df7fd345fca5a8f0dc2ea25 Mon Sep 17 00:00:00 2001 From: Julius Osokinas Date: Sat, 3 Nov 2018 15:50:07 +0000 Subject: [PATCH 08/11] Don't specify for Travis to install lxml (as it will be installed) --- travis_ci/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/travis_ci/requirements.txt b/travis_ci/requirements.txt index 300dd01..d9a8e57 100644 --- a/travis_ci/requirements.txt +++ b/travis_ci/requirements.txt @@ -1,4 +1,3 @@ django-debug-toolbar factory-boy coveralls -lxml==4.2.5 From 573d474b2ad84f41cf5b1c53226ad38908819c9c Mon Sep 17 00:00:00 2001 From: Julius Osokinas Date: Sat, 3 Nov 2018 16:11:54 +0000 Subject: [PATCH 09/11] Test with Python 3 on Travis CI --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f1fa7ff..8fd5887 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ services: python: - '2.7' + - '3.6' addons: postgresql: '9.4' @@ -54,4 +55,5 @@ deploy: on: tags: true branch: master + python: '3.6' condition: $DEPLOY = 1 From 9dc1868ab9f8322f56b8782170aceca9f0f62a76 Mon Sep 17 00:00:00 2001 From: Julius Osokinas Date: Sat, 3 Nov 2018 16:17:58 +0000 Subject: [PATCH 10/11] Use system site packages only with Python 2.7 (on Travis CI) --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8fd5887..7a59998 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ services: - postgresql python: - - '2.7' + - '2.7_with_system_site_packages' - '3.6' addons: @@ -18,9 +18,6 @@ env: - GEOKEY='>=1.6,<1.7' DJANGO='>=1.11,<1.12' DEPLOY=0 - GEOKEY='>=1.7,<1.8' DJANGO='>=1.11,<1.12' DEPLOY=1 -virtualenv: - system_site_packages: true - install: - sudo -E apt-get -yq update &>> ~/apt-get-update.log - sudo apt-get install binutils libav-tools From 4a4629e1f96bd6b5391628859c55c43ac023d585 Mon Sep 17 00:00:00 2001 From: Julius Osokinas Date: Sat, 3 Nov 2018 19:43:11 +0000 Subject: [PATCH 11/11] Add info about Python 3.6 version being supported --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2d2c1ac..2098012 100644 --- a/README.rst +++ b/README.rst @@ -20,7 +20,7 @@ Install geokey-epicollect requires: -- Python version 2.7 +- Python version 2.7 or 3.6 - GeoKey version 1.6 or greater Make sure the dependencies are installed: