Add Django 2.0 support (#68)
Add Django 2.0 support
* Don't test Django 2 against Python 2
* Dont test Django 1.9 against Python 2.6
André Luiz authored 6 years ago
Mike Grouchy committed 6 years ago
13 | 13 |
- DJANGO_VERSION="django>=1.9,<1.10"
|
14 | 14 |
- DJANGO_VERSION="django>=1.10,<1.11"
|
15 | 15 |
- DJANGO_VERSION="django>=1.11,<1.12"
|
|
16 |
- DJANGO_VERSION="django>=2.0,<2.1"
|
16 | 17 |
matrix:
|
17 | 18 |
exclude:
|
18 | 19 |
- python: "2.6"
|
|
25 | 26 |
env: DJANGO_VERSION="django>=1.10,<1.11"
|
26 | 27 |
- python: "2.6"
|
27 | 28 |
env: DJANGO_VERSION="django>=1.11,<1.12"
|
|
29 |
- python: "2.6"
|
|
30 |
env: DJANGO_VERSION="django>=2.0,<2.1"
|
|
31 |
- python: "2.7"
|
|
32 |
env: DJANGO_VERSION="django>=2.0,<2.1"
|
28 | 33 |
- python: "3.4"
|
29 | 34 |
env: DJANGO_VERSION="django>=1.4,<1.5"
|
30 | 35 |
- python: "3.4"
|
0 | 0 |
import re
|
1 | 1 |
|
2 | |
from django.core.urlresolvers import reverse, NoReverseMatch
|
|
2 |
try:
|
|
3 |
from django.urls import reverse, NoReverseMatch
|
|
4 |
except ImportError:
|
|
5 |
from django.core.urlresolvers import reverse, NoReverseMatch
|
3 | 6 |
from django.conf import settings
|
4 | 7 |
from django.contrib.auth.decorators import login_required
|
5 | |
|
6 | 8 |
|
7 | 9 |
STRONGHOLD_PUBLIC_URLS = getattr(settings, 'STRONGHOLD_PUBLIC_URLS', ())
|
8 | 10 |
STRONGHOLD_DEFAULTS = getattr(settings, 'STRONGHOLD_DEFAULTS', True)
|
9 | 11 |
STRONGHOLD_PUBLIC_NAMED_URLS = getattr(settings, 'STRONGHOLD_PUBLIC_NAMED_URLS', ())
|
10 | |
STRONGHOLD_USER_TEST_FUNC = getattr(
|
11 | |
settings,
|
12 | |
'STRONGHOLD_USER_TEST_FUNC',
|
13 | |
lambda u: u.is_authenticated()
|
14 | |
)
|
|
12 |
|
|
13 |
def is_authenticated(user):
|
|
14 |
""" make compatible with django 1 and 2 """
|
|
15 |
try:
|
|
16 |
return user.is_authenticated()
|
|
17 |
except TypeError:
|
|
18 |
return user.is_authenticated
|
|
19 |
|
|
20 |
STRONGHOLD_USER_TEST_FUNC = getattr(settings, 'STRONGHOLD_USER_TEST_FUNC', is_authenticated)
|
15 | 21 |
|
16 | 22 |
|
17 | 23 |
if STRONGHOLD_DEFAULTS:
|
3 | 3 |
from stronghold import conf
|
4 | 4 |
from stronghold.middleware import LoginRequiredMiddleware
|
5 | 5 |
|
6 | |
from django.core.urlresolvers import reverse
|
|
6 |
try:
|
|
7 |
from django.urls import reverse
|
|
8 |
except ImportError:
|
|
9 |
from django.core.urlresolvers import reverse
|
|
10 |
|
7 | 11 |
from django.http import HttpResponse
|
8 | 12 |
from django.test import TestCase
|
9 | 13 |
from django.test.client import RequestFactory
|