Codebase list django-stronghold / 3f4d160
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
5 changed file(s) with 29 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
1313 - DJANGO_VERSION="django>=1.9,<1.10"
1414 - DJANGO_VERSION="django>=1.10,<1.11"
1515 - DJANGO_VERSION="django>=1.11,<1.12"
16 - DJANGO_VERSION="django>=2.0,<2.1"
1617 matrix:
1718 exclude:
1819 - python: "2.6"
2526 env: DJANGO_VERSION="django>=1.10,<1.11"
2627 - python: "2.6"
2728 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"
2833 - python: "3.4"
2934 env: DJANGO_VERSION="django>=1.4,<1.5"
3035 - python: "3.4"
147147 **Default**:
148148
149149 ```python
150 STRONGHOLD_USER_TEST_FUNC = lambda user: user.is_authenticated()
150 STRONGHOLD_USER_TEST_FUNC = lambda user: user.is_authenticated
151151 ```
152152
153153 ##Compatiblity
160160 * Django 1.8.x
161161 * Django 1.9.x
162162 * Django 1.10.x
163 * Django 1.11.x
164 * Django 2.0.x
163165
164166 ## Contribute
165167
167167 **Default**:
168168
169169 .. code:: python
170 STRONGHOLD_USER_TEST_FUNC = lambda user: user.is_authenticated()
170 STRONGHOLD_USER_TEST_FUNC = lambda user: user.is_authenticated
171171
172172
173173 Compatiblity
182182 - Django 1.8.x
183183 - Django 1.9.x
184184 - Django 1.10.x
185 - Django 1.11.x
186 - Django 2.0.x
185187
186188 Contribute
187189 ----------
00 import re
11
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
36 from django.conf import settings
47 from django.contrib.auth.decorators import login_required
5
68
79 STRONGHOLD_PUBLIC_URLS = getattr(settings, 'STRONGHOLD_PUBLIC_URLS', ())
810 STRONGHOLD_DEFAULTS = getattr(settings, 'STRONGHOLD_DEFAULTS', True)
911 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)
1521
1622
1723 if STRONGHOLD_DEFAULTS:
33 from stronghold import conf
44 from stronghold.middleware import LoginRequiredMiddleware
55
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
711 from django.http import HttpResponse
812 from django.test import TestCase
913 from django.test.client import RequestFactory