Permalink
Browse files

Migrate to Django2, drop Python2 support

  • Loading branch information...
jochenklar committed Nov 6, 2018
1 parent 230349a commit 745f21555c56dbec4e372e9c7b5bdf822431b5f1
Showing with 381 additions and 290 deletions.
  1. +1 −1 .travis.yml
  2. +21 −0 daiquiri/archive/migrations/0005_django2.py
  3. +1 −8 daiquiri/archive/models.py
  4. +0 −2 daiquiri/archive/tasks.py
  5. +1 −1 daiquiri/archive/tests/test_viewsets.py
  6. +4 −3 daiquiri/archive/urls.py
  7. +1 −1 daiquiri/archive/viewsets.py
  8. +1 −1 daiquiri/auth/adapter.py
  9. +17 −0 daiquiri/auth/migrations/0012_django2.py
  10. +2 −7 daiquiri/auth/models.py
  11. +1 −1 daiquiri/auth/serializers.py
  12. +1 −1 daiquiri/auth/tests/test_accounts.py
  13. +10 −10 daiquiri/auth/urls_accounts.py
  14. +6 −3 daiquiri/auth/urls_auth.py
  15. +1 −1 daiquiri/auth/utils.py
  16. +1 −1 daiquiri/auth/views.py
  17. +3 −2 daiquiri/conesearch/urls.py
  18. +17 −0 daiquiri/contact/migrations/0005_django2.py
  19. +0 −6 daiquiri/contact/models.py
  20. +7 −4 daiquiri/contact/urls.py
  21. +1 −3 daiquiri/core/adapter/database/base.py
  22. +1 −2 daiquiri/core/adapter/download/base.py
  23. +2 −1 daiquiri/core/management/commands/rabbitcreate.py
  24. +2 −2 daiquiri/core/managers.py
  25. +3 −2 daiquiri/core/renderers.py
  26. +2 −3 daiquiri/core/settings/base.py
  27. +0 −2 daiquiri/core/tasks.py
  28. +1 −1 daiquiri/core/templatetags/core_tags.py
  29. +3 −4 daiquiri/core/utils.py
  30. +6 −6 daiquiri/core/views.py
  31. +4 −2 daiquiri/cutout/urls.py
  32. +17 −0 daiquiri/files/migrations/0004_django2.py
  33. +0 −4 daiquiri/files/models.py
  34. +4 −2 daiquiri/files/urls.py
  35. +1 −1 daiquiri/jobs/managers.py
  36. +17 −0 daiquiri/jobs/migrations/0016_django2.py
  37. +1 −7 daiquiri/jobs/models.py
  38. +1 −1 daiquiri/jobs/tests/mixins.py
  39. +2 −2 daiquiri/jobs/viewsets.py
  40. +25 −0 daiquiri/meetings/migrations/0013_django2.py
  41. +4 −13 daiquiri/meetings/models.py
  42. +13 −14 daiquiri/meetings/urls.py
  43. +29 −0 daiquiri/metadata/migrations/0024_django2.py
  44. +2 −15 daiquiri/metadata/models.py
  45. +8 −5 daiquiri/metadata/urls.py
  46. +29 −0 daiquiri/query/migrations/0021_django2.py
  47. +4 −15 daiquiri/query/models.py
  48. +1 −2 daiquiri/query/process.py
  49. +0 −2 daiquiri/query/tasks.py
  50. +1 −1 daiquiri/query/tests/test_viewsets.py
  51. +8 −5 daiquiri/query/urls.py
  52. +3 −3 daiquiri/query/utils.py
  53. +1 −1 daiquiri/query/validators.py
  54. +2 −2 daiquiri/query/viewsets.py
  55. +0 −2 daiquiri/serve/tasks.py
  56. +7 −5 daiquiri/serve/urls.py
  57. +17 −0 daiquiri/stats/migrations/0005_django2.py
  58. +0 −6 daiquiri/stats/models.py
  59. +4 −2 daiquiri/stats/urls.py
  60. +2 −6 daiquiri/tap/models.py
  61. +1 −1 daiquiri/tap/tests/test_async.py
  62. +1 −1 daiquiri/tap/tests/test_sync.py
  63. +9 −7 daiquiri/tap/urls.py
  64. +5 −3 daiquiri/uws/urls.py
  65. +0 −1 daiquiri/wordpress/rules.py
  66. +0 −2 daiquiri/wordpress/tasks.py
  67. +7 −37 docs/prerequisites.md
  68. +18 −26 setup.py
  69. +0 −1 testing/config/settings/base.py
  70. +16 −14 testing/config/urls.py
@@ -2,10 +2,10 @@ language: python
cache: pip

python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7

addons:
mariadb: '10.1'
@@ -0,0 +1,21 @@
# Generated by Django 2.1.3 on 2018-11-05 16:59

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('daiquiri_archive', '0004_python3'),
]

operations = [
migrations.AlterModelOptions(
name='archivejob',
options={'ordering': ('start_time',), 'verbose_name': 'ArchiveJob', 'verbose_name_plural': 'ArchiveJobs'},
),
migrations.AlterModelOptions(
name='collection',
options={'ordering': ('name',), 'verbose_name': 'Collection', 'verbose_name_plural': 'Collections'},
),
]
@@ -1,13 +1,11 @@
import logging
import os
import six
import uuid

from django.conf import settings
from django.contrib.auth.models import Group
from django.db import models
from django.http.request import QueryDict
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

from rest_framework.exceptions import ValidationError
@@ -25,7 +23,6 @@
logger = logging.getLogger(__name__)


@python_2_unicode_compatible
class Collection(models.Model):

objects = AccessLevelManager()
@@ -51,8 +48,6 @@ class Meta:
verbose_name = _('Collection')
verbose_name_plural = _('Collections')

permissions = (('view_collection', 'Can view Collection'),)

def __str__(self):
return self.name

@@ -76,8 +71,6 @@ class Meta:
verbose_name = _('ArchiveJob')
verbose_name_plural = _('ArchiveJobs')

permissions = (('view_archivejob', 'Can view ArchiveJob'),)


@property
def file_path(self):
@@ -139,7 +132,7 @@ def process(self):
})

# get the index of the path column in the row
path_index = six.next((i for i, column in enumerate(settings.ARCHIVE_COLUMNS) if column['name'] == 'path'))
path_index = next((i for i, column in enumerate(settings.ARCHIVE_COLUMNS) if column['name'] == 'path'))

for row in rows:
# append the file to the list of files only if it exists on the filesystem
@@ -1,5 +1,3 @@
from __future__ import absolute_import, unicode_literals

import logging
import os
import zipfile
@@ -2,7 +2,7 @@

from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.test import TestCase

from test_generator.viewsets import TestViewsetMixin, TestListViewsetMixin
@@ -1,10 +1,11 @@
from django.conf.urls import url, include
from django.urls import include, path

from rest_framework import routers

from .views import ArchiveView
from .viewsets import RowViewSet, ColumnViewSet, FileViewSet, ArchiveViewSet

app_name = 'archive'

router = routers.DefaultRouter()
router.register(r'rows', RowViewSet, base_name='row')
@@ -13,8 +14,8 @@
router.register(r'archives', ArchiveViewSet, base_name='archive')

urlpatterns = [
url(r'^$', ArchiveView.as_view(), name='archive'),
path('', ArchiveView.as_view(), name='archive'),

# rest api
url(r'^api/', include(router.urls)),
path('api/', include(router.urls)),
]
@@ -139,7 +139,7 @@ def create(self, request):

except ArchiveJob.DoesNotExist:
archive_job = ArchiveJob(
owner=(None if self.request.user.is_anonymous() else self.request.user),
owner=(None if self.request.user.is_anonymous else self.request.user),
client_ip=get_client_ip(self.request),
data=request.data
)
@@ -1,7 +1,7 @@
import logging

from django.conf import settings
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import HttpResponseRedirect

from allauth.account.adapter import DefaultAccountAdapter
@@ -0,0 +1,17 @@
# Generated by Django 2.1.3 on 2018-11-05 16:59

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('daiquiri_auth', '0011_meta'),
]

operations = [
migrations.AlterModelOptions(
name='profile',
options={'ordering': ('user__last_name', 'user__last_name', 'user__username'), 'verbose_name': 'Profile', 'verbose_name_plural': 'Profiles'},
),
]
@@ -1,10 +1,7 @@
from __future__ import unicode_literals

import logging

from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

from jsonfield import JSONField
@@ -21,10 +18,10 @@
logger = logging.getLogger(__name__)


@python_2_unicode_compatible
class Profile(models.Model):

user = models.OneToOneField(User)
user = models.OneToOneField(User, on_delete=models.CASCADE)

is_pending = models.BooleanField(
default=False,
help_text='Designates whether the user waiting on confirmation by a manager.')
@@ -45,8 +42,6 @@ class Meta:
verbose_name = _('Profile')
verbose_name_plural = _('Profiles')

permissions = (('view_profile', 'Can view Profile'),)

def __str__(self):
return self.user.username

@@ -65,7 +65,7 @@ def update(self, obj, validated_data):
# update the user for this profile seperately
obj.user.first_name = user['first_name']
obj.user.last_name = user['last_name']
obj.user.groups = user['groups']
obj.user.groups.set(user['groups'])
obj.user.save()

return super(ProfileSerializer, self).update(obj, validated_data)
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.test import TestCase

from ..models import Profile
@@ -1,21 +1,21 @@
from django.conf.urls import url, include
from django.urls import include, re_path
from django.views.generic import TemplateView

from .views import profile_update, profile_json, token, logout, password_change, password_set


urlpatterns = [
url(r'^profile/$', profile_update, name='account_profile'),
url(r'^profile.json/$', profile_json, name='account_profile_json'),
url(r'^token/$', token, name='account_token'),
url(r'^pending/$', TemplateView.as_view(template_name='account/account_pending.html'), name='account_pending'),
re_path(r'^profile/$', profile_update, name='account_profile'),
re_path(r'^profile.json/$', profile_json, name='account_profile_json'),
re_path(r'^token/$', token, name='account_token'),
re_path(r'^pending/$', TemplateView.as_view(template_name='account/account_pending.html'), name='account_pending'),

# override login by allauth to remove wordpress cookies
url(r"^logout/$", logout, name="account_logout"),
re_path(r"^logout/$", logout, name="account_logout"),

# include allauth patterns
url(r'^password/change/$', password_change, name='account_change_password'),
url(r'^password/change/done/$', TemplateView.as_view(template_name='account/password_change_done.html'), name='account_change_password_done'),
url(r'^password/set/$', password_set, name='account_password_set'),
url(r'^', include('allauth.urls')),
re_path(r'^password/change/$', password_change, name='account_change_password'),
re_path(r'^password/change/done/$', TemplateView.as_view(template_name='account/password_change_done.html'), name='account_change_password_done'),
re_path(r'^password/set/$', password_set, name='account_password_set'),
re_path(r'^', include('allauth.urls')),
]
@@ -1,18 +1,21 @@
from django.conf.urls import url, include
from django.urls import include, path

from rest_framework import routers

from .views import UsersView
from .viewsets import ProfileViewSet, GroupViewSet


app_name = 'auth'

router = routers.DefaultRouter()
router.register(r'profiles', ProfileViewSet)
router.register(r'groups', GroupViewSet)

urlpatterns = [
# user management
url(r'^users/', UsersView.as_view(), name='users'),
path('users/', UsersView.as_view(), name='users'),

# rest api
url(r'^api/', include(router.urls)),
path('api/', include(router.urls)),
]
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.models import User, Permission
from django.db.models import Q

@@ -2,7 +2,7 @@

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.urls import reverse
from daiquiri.core.utils import get_referer_path_info, get_next
from django.views.generic import TemplateView
from django.http import HttpResponseRedirect, JsonResponse
@@ -1,8 +1,9 @@
from django.conf.urls import url
from django.urls import re_path

from .viewsets import ConeSearchView

app_name = 'conesearch'

urlpatterns = [
url(r'^api/(?P<resource>.+)/$', ConeSearchView.as_view(), name='search'),
re_path(r'^api/(?P<resource>.+)/$', ConeSearchView.as_view(), name='search'),
]
@@ -0,0 +1,17 @@
# Generated by Django 2.1.3 on 2018-11-05 16:59

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('daiquiri_contact', '0004_meta'),
]

operations = [
migrations.AlterModelOptions(
name='contactmessage',
options={'ordering': ('-created', 'author'), 'verbose_name': 'Contact message', 'verbose_name_plural': 'Contact messages'},
),
]
@@ -1,12 +1,8 @@
from __future__ import unicode_literals

from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _


@python_2_unicode_compatible
class ContactMessage(models.Model):

STATUS_ACTIVE = 'ACTIVE'
@@ -34,8 +30,6 @@ class Meta:
verbose_name = _('Contact message')
verbose_name_plural = _('Contact messages')

permissions = (('view_contactmessage', 'Can view ContactMessage'),)

def __str__(self):
return "created=%s; email=%s; subject=%s; status=%s" % (self.created, self.email, self.subject, self.status)

@@ -1,18 +1,21 @@
from django.conf.urls import url, include
from django.urls import include, path

from rest_framework import routers

from .views import contact, MessagesView
from .viewsets import ContactMessageViewSet, StatusViewSet


app_name = 'contact'

router = routers.DefaultRouter()
router.register(r'messages', ContactMessageViewSet, base_name='message')
router.register(r'status', StatusViewSet, base_name='status')

urlpatterns = [
url(r'^$', contact, name='contact'),
url(r'^messages/', MessagesView.as_view(), name='messages'),
path('', contact, name='contact'),
path('messages/', MessagesView.as_view(), name='messages'),

# rest api
url(r'^api/', include(router.urls)),
path('api/', include(router.urls)),
]
@@ -1,5 +1,3 @@
import six

from django.db import connections


@@ -122,7 +120,7 @@ def _process_filtering(self, sql, sql_args, search, filters, escaped_column_name
escaped_column_name = self.escape_identifier(column_name)

# check if the filter is a list or a string
if isinstance(column_filter, six.string_types):
if isinstance(column_filter, str):
filter_list = [column_filter]
elif isinstance(column_filter, list):
filter_list = column_filter
@@ -1,6 +1,5 @@
import logging
import csv
import six
import subprocess
import re

@@ -75,7 +74,7 @@ def generate_rows(self, prepend=None):
if insert_result:
line = insert_result.group(1)
reader = csv.reader([line], quotechar="'", skipinitialspace=True)
row = six.next(reader)
row = next(reader)

if prepend:
yield [(prepend[i] + cell if (i in prepend and cell != 'NULL') else cell) for i, cell in enumerate(row)]
@@ -1,6 +1,7 @@
from urllib.parse import urlparse

from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils.six.moves.urllib.parse import urlparse


class Command(BaseCommand):
Oops, something went wrong.

0 comments on commit 745f215

Please sign in to comment.