Skip to content

Commit dcd2c50

Browse files
committed
Merge branch 'develop'
2 parents df618e6 + dc03368 commit dcd2c50

File tree

9 files changed

+51
-11
lines changed

9 files changed

+51
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 1.4.0
2+
- Compatibility with Django 2.0 (https://github.com/kstateome/django-cas/pull/72)
3+
14
### 1.3.0
25
- Compatibility with Django 1.10 Middleware (https://github.com/kstateome/django-cas/pull/69)
36
- Add support for protocol-rooted URL as "next_page" argument for _logout_url constructor (https://github.com/kstateome/django-cas/pull/67)

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ bryankaplan
44
cordmata
55
bltravis
66
JordanReiter
7+
balsdorf

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
CAS client for Django. This library requires Django 1.5 or above, and Python 2.6, 2.7, 3.4
44

5-
Current version: 1.3.0
5+
Current version: 1.4.0
66

77
This is [K-State's fork](https://github.com/kstateome/django-cas) of [the original](https://bitbucket.org/cpcc/django-cas/overview) and includes [several additional features](https://github.com/kstateome/django-cas/#additional-features) as well as features merged from
88

@@ -14,7 +14,7 @@ This is [K-State's fork](https://github.com/kstateome/django-cas) of [the or
1414

1515
This project is registered on PyPi as django-cas-client. To install::
1616

17-
pip install django-cas-client==1.3.0
17+
pip install django-cas-client==1.4.0
1818

1919

2020
### Add to URLs

cas/decorators.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIE
2929
def decorator(view_func):
3030
@wraps(view_func)
3131
def wrapper(request, *args, **kwargs):
32+
33+
try:
34+
# use callable for pre-django 2.0
35+
is_authenticated = request.user.is_authenticated()
36+
except TypeError:
37+
is_authenticated = request.user.is_authenticated
38+
3239
if test_func(request.user):
3340
return view_func(request, *args, **kwargs)
34-
elif request.user.is_authenticated():
41+
elif is_authenticated:
3542
return HttpResponseForbidden('<h1>Permission denied</h1>')
3643
else:
3744
path = '%s?%s=%s' % (login_url, redirect_field_name,
@@ -65,7 +72,13 @@ def wrapped_f(*args):
6572
from cas.views import login
6673
request = args[0]
6774

68-
if request.user.is_authenticated():
75+
try:
76+
# use callable for pre-django 2.0
77+
is_authenticated = request.user.is_authenticated()
78+
except TypeError:
79+
is_authenticated = request.user.is_authenticated
80+
81+
if is_authenticated:
6982
# Is Authed, fine
7083
pass
7184
else:

cas/middleware.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
from django.contrib.auth import REDIRECT_FIELD_NAME
1010
from django.contrib.auth import logout as do_logout
1111
from django.contrib.auth.views import login, logout
12-
from django.core.urlresolvers import reverse
1312
from django.http import HttpResponseRedirect, HttpResponseForbidden
1413
from django.core.exceptions import ImproperlyConfigured
14+
try:
15+
from django.urls import reverse
16+
except ImportError:
17+
from django.core.urlresolvers import reverse
1518
try:
1619
from django.utils.deprecation import MiddlewareMixin
1720
except ImportError:
@@ -60,7 +63,13 @@ def process_view(self, request, view_func, view_args, view_kwargs):
6063
elif not view_func.__module__.startswith('django.contrib.admin.'):
6164
return None
6265

63-
if request.user.is_authenticated():
66+
try:
67+
# use callable for pre-django 2.0
68+
is_authenticated = request.user.is_authenticated()
69+
except TypeError:
70+
is_authenticated = request.user.is_authenticated
71+
72+
if is_authenticated:
6473
if request.user.is_staff:
6574
return None
6675
else:

cas/views.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
from django.conf import settings
1717
from django.contrib.auth import REDIRECT_FIELD_NAME
1818
from django.contrib import auth
19-
from django.core.urlresolvers import reverse
19+
20+
try:
21+
from django.urls import reverse
22+
except ImportError:
23+
from django.core.urlresolvers import reverse
2024

2125
from cas.models import PgtIOU
2226

@@ -166,7 +170,13 @@ def login(request, next_page=None, required=False, gateway=False):
166170
if not next_page:
167171
next_page = _redirect_url(request)
168172

169-
if request.user.is_authenticated():
173+
try:
174+
# use callable for pre-django 2.0
175+
is_authenticated = request.user.is_authenticated()
176+
except TypeError:
177+
is_authenticated = request.user.is_authenticated
178+
179+
if is_authenticated:
170180
return HttpResponseRedirect(next_page)
171181

172182
ticket = request.GET.get('ticket')

docs/source/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
1.4.0
5+
------------------
6+
- Compatibility with Django 2.0 (https://github.com/kstateome/django-cas/pull/72)
7+
48
1.3.0
59
------------------
610

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
# built documents.
5959
#
6060
# The short X.Y version.
61-
version = '1.3.0'
61+
version = '1.4.0'
6262
# The full version, including alpha/beta/rc tags.
63-
release = '1.3.0'
63+
release = '1.4.0'
6464

6565
# The language for content autogenerated by Sphinx. Refer to documentation
6666
# for a list of supported languages.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup, find_packages
44

5-
version = '1.3.0'
5+
version = '1.4.0'
66

77

88
def read(fname):

0 commit comments

Comments
 (0)