From e3b6de9b1e0ef4bab0d39d76825e23d41d7960fa Mon Sep 17 00:00:00 2001 From: kimarakov Date: Sun, 24 Sep 2017 10:27:33 -0700 Subject: [PATCH] Add support for upcoming Django 2.0; drop support for Django < 1.11 Django 2.0 is scheduled to be released later this year. See: https://code.djangoproject.com/wiki/Version2.0Roadmap Can begin testing for compatibility and bugs now. Django 2.0 is not backwards compatible with Django < 1.11, so support was dropped. The backwards compatibility is documented: https://docs.djangoproject.com/en/dev/internals/release-process/#deprecation-policy Supports schedules documented: https://www.djangoproject.com/download/#supported-versions --- .travis.yml | 28 +++++++-------------------- README.md | 4 ++-- docs/settings.txt | 4 ++-- requirements.txt | 6 +++++- runtests.py | 20 ------------------- schedule/models/calendars.py | 2 +- schedule/models/events.py | 2 +- schedule/settings.py | 4 ++-- schedule/templatetags/scheduletags.py | 4 ++-- schedule/views.py | 2 +- setup.py | 7 ++----- tests/settings.py | 2 +- tests/test_event.py | 2 +- tests/test_perms.py | 2 +- tests/test_views.py | 2 +- 15 files changed, 29 insertions(+), 62 deletions(-) delete mode 100755 runtests.py diff --git a/.travis.yml b/.travis.yml index 8daf9fd..c9a6613 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,26 +4,6 @@ cache: pip matrix: include: - - python: 2.7 - env: DJANGO="Django>=1.8,<1.9" - - python: 3.3 - env: DJANGO="Django>=1.8,<1.9" - - python: 3.4 - env: DJANGO="Django>=1.8,<1.9" - - python: 3.5 - env: DJANGO="Django>=1.8,<1.9" - - python: 2.7 - env: DJANGO="Django>=1.9,<1.10" - - python: 3.4 - env: DJANGO="Django>=1.9,<1.10" - - python: 3.5 - env: DJANGO="Django>=1.9,<1.10" - - python: 2.7 - env: DJANGO="Django>=1.10,<1.11" - - python: 3.4 - env: DJANGO="Django>=1.10,<1.11" - - python: 3.5 - env: DJANGO="Django>=1.10,<1.11" - python: 2.7 env: DJANGO="Django>=1.11,<2.0" - python: 3.4 @@ -32,6 +12,12 @@ matrix: env: DJANGO="Django>=1.11,<2.0" - python: 3.6 env: DJANGO="Django>=1.11,<2.0" + - python: 3.4 + env: DJANGO="Django>=2.0,<2.1" + - python: 3.5 + env: DJANGO="Django>=2.0,<2.1" + - python: 3.6 + env: DJANGO="Django>=2.0,<2.1" install: - pip install $DJANGO @@ -40,7 +26,7 @@ before_script: - flake8 - isort --check-only --diff script: - - coverage run runtests.py + - coverage run -m django test --settings=tests.settings - coverage report -m after_success: - coveralls --verbose diff --git a/README.md b/README.md index 50d55fa..988c036 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ This setting controls the callable used to determine if a user has permission to Default: ```python check_edit_permission(ob, user): - return user.is_authenticated() + return user.is_authenticated ``` If ob is None, then the function is checking for permission to add new events @@ -163,7 +163,7 @@ This setting controls the callable used to determine if a user has permission to Default: ```python check_edit_permission(ob, user): - return user.is_authenticated() + return user.is_authenticated ``` ### GET_EVENTS_FUNC diff --git a/docs/settings.txt b/docs/settings.txt index 5d25b37..7f986a9 100644 --- a/docs/settings.txt +++ b/docs/settings.txt @@ -29,7 +29,7 @@ This setting controls the callable used to determine if a user has permission to example:: check_edit_permission(ob, user): - return user.is_authenticated() + return user.is_authenticated If ob is None, then the function is checking for permission to add new events. @@ -43,7 +43,7 @@ This setting controls the callable used to determine if a user has permission to example:: check_edit_permission(ob, user): - return user.is_authenticated() + return user.is_authenticated .. _ref-settings-get-events-func: diff --git a/requirements.txt b/requirements.txt index d21f47c..1821f00 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,11 @@ --e . coverage>=3.7.1 coveralls>=0.5 +django-annoying>=0.8.0 +Django>=1.11 flake8 +icalendar>=3.8.4 isort mock +python-dateutil>=2.1 +pytz>=2013.9 wheel diff --git a/runtests.py b/runtests.py deleted file mode 100755 index 851778d..0000000 --- a/runtests.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -import django -from django.conf import settings -from django.test.utils import get_runner - - -def runtests(): - os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' - django.setup() - TestRunner = get_runner(settings) - test_runner = TestRunner() - failures = test_runner.run_tests(["tests"]) - sys.exit(bool(failures)) - - -if __name__ == "__main__": - runtests() diff --git a/schedule/models/calendars.py b/schedule/models/calendars.py index 0a3e231..a59e424 100644 --- a/schedule/models/calendars.py +++ b/schedule/models/calendars.py @@ -3,11 +3,11 @@ from django.contrib.contenttypes import fields from django.contrib.contenttypes.models import ContentType -from django.core.urlresolvers import reverse from django.db import models from django.db.models import Q from django.db.models.base import ModelBase from django.template.defaultfilters import slugify +from django.urls import reverse from django.utils import timezone from django.utils.encoding import python_2_unicode_compatible from django.utils.six import with_metaclass diff --git a/schedule/models/events.py b/schedule/models/events.py index 549ad7c..857731e 100644 --- a/schedule/models/events.py +++ b/schedule/models/events.py @@ -7,11 +7,11 @@ from django.conf import settings as django_settings from django.contrib.contenttypes import fields from django.contrib.contenttypes.models import ContentType -from django.core.urlresolvers import reverse from django.db import models from django.db.models import Q from django.db.models.base import ModelBase from django.template.defaultfilters import date +from django.urls import reverse from django.utils import timezone from django.utils.encoding import python_2_unicode_compatible from django.utils.six import with_metaclass diff --git a/schedule/settings.py b/schedule/settings.py index bd9c236..f8aef7e 100644 --- a/schedule/settings.py +++ b/schedule/settings.py @@ -12,7 +12,7 @@ if not CHECK_EVENT_PERM_FUNC: def check_event_permission(ob, user): - return user.is_authenticated() + return user.is_authenticated CHECK_EVENT_PERM_FUNC = check_event_permission @@ -31,7 +31,7 @@ def check_occurrence_permission(ob, user): if not CHECK_CALENDAR_PERM_FUNC: def check_calendar_permission(ob, user): - return user.is_authenticated() + return user.is_authenticated CHECK_CALENDAR_PERM_FUNC = check_calendar_permission diff --git a/schedule/templatetags/scheduletags.py b/schedule/templatetags/scheduletags.py index 3a4d5ed..85b3d67 100644 --- a/schedule/templatetags/scheduletags.py +++ b/schedule/templatetags/scheduletags.py @@ -4,7 +4,7 @@ from django import template from django.conf import settings -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils import timezone from django.utils.dateformat import format from django.utils.html import escape @@ -62,7 +62,7 @@ def daily_table(context, day, start=8, end=20, increment=30): user = context['request'].user addable = CHECK_EVENT_PERM_FUNC(None, user) if 'calendar' in context: - addable &= CHECK_CALENDAR_PERM_FUNC(context['calendar'], user) + addable = addable and CHECK_CALENDAR_PERM_FUNC(context['calendar'], user) context['addable'] = addable day_part = day.get_time_slot(day.start + datetime.timedelta(hours=start), day.start + datetime.timedelta(hours=end)) # get slots to display on the left diff --git a/schedule/views.py b/schedule/views.py index b5931eb..2676f64 100644 --- a/schedule/views.py +++ b/schedule/views.py @@ -3,12 +3,12 @@ import dateutil.parser import pytz from django.conf import settings -from django.core.urlresolvers import reverse from django.db.models import F, Q from django.http import ( Http404, HttpResponseBadRequest, HttpResponseRedirect, JsonResponse, ) from django.shortcuts import get_object_or_404 +from django.urls import reverse from django.utils import timezone from django.utils.http import is_safe_url from django.utils.six.moves.urllib.parse import quote diff --git a/setup.py b/setup.py index c6c8bff..931ec7f 100755 --- a/setup.py +++ b/setup.py @@ -29,19 +29,16 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Framework :: Django', - 'Framework :: Django :: 1.8', - 'Framework :: Django :: 1.9', - 'Framework :: Django :: 1.10', 'Framework :: Django :: 1.11', + 'Framework :: Django :: 2.0', 'Topic :: Utilities', ], install_requires=[ - 'Django>=1.8', + 'Django>=1.11', 'python-dateutil>=2.1', 'pytz>=2013.9', 'icalendar>=3.8.4', diff --git a/tests/settings.py b/tests/settings.py index 3da0989..83d9df9 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -24,7 +24,7 @@ } ] -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/tests/test_event.py b/tests/test_event.py index ba48491..2b06807 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -2,9 +2,9 @@ import pytz from django.contrib.auth.models import User -from django.core.urlresolvers import reverse from django.test import TestCase from django.test.utils import override_settings +from django.urls import reverse from django.utils import timezone from schedule.models import Calendar, Event, EventRelation, Rule diff --git a/tests/test_perms.py b/tests/test_perms.py index 7a69c39..852a870 100644 --- a/tests/test_perms.py +++ b/tests/test_perms.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from django.contrib.auth.models import User -from django.core.urlresolvers import reverse from django.test import TestCase +from django.urls import reverse from django.utils import timezone from schedule import utils diff --git a/tests/test_views.py b/tests/test_views.py index 189e419..278aada 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -4,9 +4,9 @@ import json import pytz -from django.core.urlresolvers import reverse from django.http import Http404 from django.test import TestCase, override_settings +from django.urls import reverse from django.utils import timezone from schedule.models.calendars import Calendar