general: remove compatibility with django < 1.11 (#38616)
This commit is contained in:
parent
320ee3c457
commit
74230b51ec
|
@ -13,7 +13,7 @@ Package: python-django-mellon
|
|||
Architecture: all
|
||||
Depends: ${misc:Depends}, ${python:Depends},
|
||||
python (>= 2.7),
|
||||
python-django (>= 1.5),
|
||||
python-django (>= 1:1.11),
|
||||
python-isodate,
|
||||
python-lasso,
|
||||
python-atomicwrites
|
||||
|
@ -23,7 +23,7 @@ Description: SAML authentication for Django
|
|||
Package: python3-django-mellon
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, ${python:Depends},
|
||||
python3-django (>= 1.5),
|
||||
python3-django (>= 1:1.11),
|
||||
python3-isodate,
|
||||
python3-lasso,
|
||||
python3-atomicwrites
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
# django-mellon - SAML2 authentication for Django
|
||||
# Copyright (C) 2014-2019 Entr'ouvert
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import django
|
||||
if django.VERSION < (1, 11, 0):
|
||||
from django.core.urlresolvers import reverse
|
||||
MiddlewareClass = object
|
||||
|
||||
is_authenticated = lambda user: user.is_authenticated()
|
||||
else:
|
||||
from django.urls import reverse
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
MiddlewareClass = MiddlewareMixin
|
||||
|
||||
is_authenticated = lambda user: user.is_authenticated
|
|
@ -17,14 +17,15 @@ from __future__ import unicode_literals
|
|||
|
||||
from django.utils.http import urlencode
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.urls import reverse
|
||||
|
||||
from . import app_settings, utils
|
||||
from .compat import reverse, MiddlewareClass, is_authenticated
|
||||
|
||||
PASSIVE_TRIED_COOKIE = 'MELLON_PASSIVE_TRIED'
|
||||
|
||||
|
||||
class PassiveAuthenticationMiddleware(MiddlewareClass):
|
||||
class PassiveAuthenticationMiddleware(MiddlewareMixin):
|
||||
def process_response(self, request, response):
|
||||
# When unlogged remove the PASSIVE_TRIED cookie
|
||||
if app_settings.OPENED_SESSION_COOKIE_NAME \
|
||||
|
@ -50,7 +51,7 @@ class PassiveAuthenticationMiddleware(MiddlewareClass):
|
|||
return
|
||||
if not app_settings.OPENED_SESSION_COOKIE_NAME:
|
||||
return
|
||||
if hasattr(request, 'user') and is_authenticated(request.user):
|
||||
if hasattr(request, 'user') and request.user.is_authenticated:
|
||||
return
|
||||
if PASSIVE_TRIED_COOKIE in request.COOKIES:
|
||||
return
|
||||
|
|
|
@ -14,6 +14,3 @@ urlpatterns = [
|
|||
url('metadata/$', views.metadata,
|
||||
name='mellon_metadata')
|
||||
]
|
||||
if django.VERSION < (1, 8):
|
||||
from django.conf.urls import patterns
|
||||
urlpatterns = patterns('', *urlpatterns)
|
||||
|
|
|
@ -25,13 +25,13 @@ from xml.parsers import expat
|
|||
import django
|
||||
from django.contrib import auth
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.utils.timezone import make_aware, now, make_naive, is_aware, get_default_timezone
|
||||
from django.conf import settings
|
||||
from django.utils.six.moves.urllib.parse import urlparse
|
||||
import lasso
|
||||
|
||||
from . import app_settings
|
||||
from .compat import reverse
|
||||
|
||||
|
||||
def create_metadata(request):
|
||||
|
|
|
@ -30,6 +30,7 @@ from django.contrib import auth
|
|||
from django.conf import settings
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.shortcuts import render, resolve_url
|
||||
from django.urls import reverse
|
||||
from django.utils.http import urlencode
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
|
@ -38,7 +39,6 @@ from django.db import transaction
|
|||
from django.utils.translation import ugettext as _
|
||||
|
||||
from . import app_settings, utils
|
||||
from .compat import reverse, is_authenticated
|
||||
|
||||
RETRY_LOGIN_COOKIE = 'MELLON_RETRY_LOGIN'
|
||||
|
||||
|
@ -529,7 +529,7 @@ class LogoutView(ProfileMixin, LogMixin, View):
|
|||
next_url = request.GET.get(REDIRECT_FIELD_NAME)
|
||||
referer = request.META.get('HTTP_REFERER')
|
||||
if not referer or utils.same_origin(referer, request.build_absolute_uri()):
|
||||
if hasattr(request, 'user') and is_authenticated(request.user):
|
||||
if hasattr(request, 'user') and request.user.is_authenticated:
|
||||
logout = None
|
||||
try:
|
||||
issuer = request.session.get('mellon_session', {}).get('issuer')
|
||||
|
|
4
setup.py
4
setup.py
|
@ -91,13 +91,13 @@ setup(name="django-mellon",
|
|||
include_package_data=True,
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'django>=1.7,<2.3',
|
||||
'django>=1.11,<2.3',
|
||||
'requests',
|
||||
'isodate',
|
||||
'atomicwrites',
|
||||
],
|
||||
setup_requires=[
|
||||
'django>=1.7,<2',
|
||||
'django>=1.10,<2.3',
|
||||
],
|
||||
tests_require=[
|
||||
'nose>=0.11.4',
|
||||
|
|
|
@ -26,6 +26,7 @@ import lasso
|
|||
import pytest
|
||||
from pytest import fixture
|
||||
|
||||
from django.urls import reverse
|
||||
from django.utils import six
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.utils.encoding import force_str
|
||||
|
@ -34,8 +35,6 @@ from mellon.utils import create_metadata
|
|||
|
||||
from httmock import all_requests, HTTMock, response as mock_response
|
||||
|
||||
from mellon.compat import reverse
|
||||
|
||||
from utils import reset_caplog
|
||||
|
||||
|
||||
|
|
|
@ -25,13 +25,12 @@ import hashlib
|
|||
from httmock import HTTMock
|
||||
|
||||
import django
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.http import urlencode
|
||||
|
||||
from xml_utils import assert_xml_constraints
|
||||
|
||||
from mellon.compat import reverse
|
||||
|
||||
from utils import error_500, html_response
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
|
|
@ -38,11 +38,10 @@ ROOT_URLCONF = 'urls_tests'
|
|||
TEMPLATE_DIRS = [
|
||||
'tests/templates/',
|
||||
]
|
||||
if django.VERSION >= (1, 8):
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'APP_DIRS': True,
|
||||
'DIRS': TEMPLATE_DIRS,
|
||||
},
|
||||
]
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'APP_DIRS': True,
|
||||
'DIRS': TEMPLATE_DIRS,
|
||||
},
|
||||
]
|
||||
|
|
4
tox.ini
4
tox.ini
|
@ -1,5 +1,5 @@
|
|||
[tox]
|
||||
envlist = coverage-py2-{dj18,dj111}-{pg,sqlite},coverage-py3-dj{111,22}-{pg,sqlite}
|
||||
envlist = coverage-py2-dj111-{pg,sqlite},coverage-py3-dj{111,22}-{pg,sqlite}
|
||||
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/django-mellon/
|
||||
|
||||
[testenv]
|
||||
|
@ -14,7 +14,6 @@ setenv =
|
|||
usedevelop =
|
||||
coverage: true
|
||||
deps =
|
||||
dj18: django>=1.8,<1.9
|
||||
dj111: django>=1.11,<1.12
|
||||
dj22: django>=2.2,<2.3
|
||||
pg: psycopg2
|
||||
|
@ -30,7 +29,6 @@ deps =
|
|||
pytz
|
||||
lxml
|
||||
cssselect
|
||||
dj18: django-webtest<1.9.3
|
||||
dj111: django-webtest<1.9.3
|
||||
dj22: django-webtest>1.9.3
|
||||
WebTest
|
||||
|
|
Loading…
Reference in New Issue