From: Radek Czajka Date: Fri, 3 Mar 2023 23:53:37 +0000 (+0100) Subject: Support Django 4.1, drop 1.11. X-Git-Tag: 23.3 X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/commitdiff_plain/14190defb1cc8b35e4f47a7b3b64788754aa1097?ds=sidebyside;hp=b88bb747c08269f187d6073504c7dca3568112b9 Support Django 4.1, drop 1.11. --- diff --git a/cas_provider/forms.py b/cas_provider/forms.py index 7f3d5b6..4a9a931 100644 --- a/cas_provider/forms.py +++ b/cas_provider/forms.py @@ -1,5 +1,5 @@ from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class LoginForm(forms.Form): diff --git a/cas_provider/models.py b/cas_provider/models.py index 4a38927..8e05337 100644 --- a/cas_provider/models.py +++ b/cas_provider/models.py @@ -1,6 +1,6 @@ from django.conf import settings from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from random import Random import string from urllib.parse import urlencode, urlparse, parse_qs, ParseResult @@ -16,9 +16,9 @@ class BaseTicket(models.Model): abstract = True def __init__(self, *args, **kwargs): - if 'ticket' not in kwargs: - kwargs['ticket'] = self._generate_ticket() super(BaseTicket, self).__init__(*args, **kwargs) + if not self.ticket: + self.ticket = self._generate_ticket() def __unicode__(self): return self.ticket @@ -65,9 +65,9 @@ class ProxyGrantingTicket(BaseTicket): prefix = 'PGT' def __init__(self, *args, **kwargs): - if 'pgtiou' not in kwargs: - kwargs['pgtiou'] = "PGTIOU-%s" % (''.join(Random().sample(string.ascii_letters + string.digits, 50))) super(ProxyGrantingTicket, self).__init__(*args, **kwargs) + if not self.pgtiou: + self.pgtiou = "PGTIOU-%s" % (''.join(Random().sample(string.ascii_letters + string.digits, 50))) class Meta: verbose_name = _('Proxy Granting Ticket') diff --git a/cas_provider/signals.py b/cas_provider/signals.py index b263078..e12f764 100644 --- a/cas_provider/signals.py +++ b/cas_provider/signals.py @@ -3,10 +3,10 @@ from django import dispatch -on_cas_collect_histories = dispatch.Signal(providing_args=["for_email"]) +on_cas_collect_histories = dispatch.Signal() -on_cas_login = dispatch.Signal(providing_args=["request"]) +on_cas_login = dispatch.Signal() -on_cas_login_success = dispatch.Signal(providing_args=["user", "service"]) +on_cas_login_success = dispatch.Signal() -cas_collect_custom_attributes = dispatch.Signal(providing_args=['user']) +cas_collect_custom_attributes = dispatch.Signal() diff --git a/cas_provider/urls.py b/cas_provider/urls.py index 9f6304b..6f479fe 100644 --- a/cas_provider/urls.py +++ b/cas_provider/urls.py @@ -1,14 +1,14 @@ -from django.conf.urls import url +from django.urls import path from cas_provider import views urlpatterns = [ - url(r'^login/merge/', views.login, {'merge': True, 'template_name': 'cas/merge.html'}), - url(r'^login/?$', views.login, name='cas_login'), - url(r'^socialauth-login/$', views.login, name='cas_socialauth_login'), - url(r'^validate/?$', views.validate, name='cas_validate'), - url(r'^proxy/?$', views.proxy, name='proxy'), - url(r'^serviceValidate/?$', views.service_validate, name='cas_service_validate'), - url(r'^proxyValidate/?$', views.proxy_validate, name='cas_proxy_validate'), - url(r'^logout/?$', views.logout, name='cas_logout'), + path('login/merge/', views.login, {'merge': True, 'template_name': 'cas/merge.html'}), + path('login/', views.login, name='cas_login'), + path('socialauth-login/', views.login, name='cas_socialauth_login'), + path('validate/', views.validate, name='cas_validate'), + path('proxy/', views.proxy, name='proxy'), + path('serviceValidate/', views.service_validate, name='cas_service_validate'), + path('proxyValidate/', views.proxy_validate, name='cas_proxy_validate'), + path('logout/', views.logout, name='cas_logout'), ] diff --git a/cas_provider/views.py b/cas_provider/views.py index 6b39131..a8e166c 100644 --- a/cas_provider/views.py +++ b/cas_provider/views.py @@ -16,10 +16,9 @@ from django.conf import settings from django.contrib.auth import login as auth_login, logout as auth_logout from django.shortcuts import render -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.template import RequestContext from django.contrib.auth import authenticate -from django.utils.translation import ugettext as _ from lxml import etree from cas_provider.attribute_formatters import NSMAP, CAS diff --git a/cas_provider_examples/simple/urls.py b/cas_provider_examples/simple/urls.py index d13d505..dfa9975 100644 --- a/cas_provider_examples/simple/urls.py +++ b/cas_provider_examples/simple/urls.py @@ -1,13 +1,10 @@ -from django.conf.urls import include, url +from django.urls import path, include from django.contrib import admin from django.views.generic import TemplateView from django import VERSION -if VERSION >= (2,): - from django.urls import path - urlpatterns = [ - url(r'^admin/', include(admin.site.urls)) if VERSION < (2,) else path('admin/', admin.site.urls), - url(r'^', include('cas_provider.urls')), - url(r'^accounts/profile', TemplateView.as_view(template_name='login-success-redirect-target.html')), + path('admin/', admin.site.urls), + path('', include('cas_provider.urls')), + path('accounts/profile/', TemplateView.as_view(template_name='login-success-redirect-target.html')), ] diff --git a/setup.py b/setup.py index 75570e1..0e7c402 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def read(fname): setup( name='django-cas-provider', - version='22.4', + version='23.3', description='A "provider" for the Central Authentication Service (http://jasig.org/cas)', author='(Chris Williams), Sebastian Annies', author_email='(chris@nitron.org), sebastian.annies@googlemail.com', @@ -17,7 +17,7 @@ setup( long_description=read('README.rst'), zip_safe=False, install_requires=[ - 'Django>=1.11,<4.1', + 'Django>=2.0,<4.2', 'lxml', ], classifiers = [ diff --git a/tox.ini b/tox.ini index 4969b0c..da84103 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] envlist=clear, - d111-py{37}, d20-py{37}, d21-py{37}, d22-py{37,38,39}, d{30,31}-py{37,38,39}, d32-py{37,38,39,310}, d40-py{38,39,310}, + d41-py{38,39,310,311}, stats [testenv] @@ -20,6 +20,7 @@ deps= d31: Django>=3.1,<3.2 d32: Django>=3.2,<4.0 d40: Django>=4.0,<4.1 + d41: Django>=4.1,<4.2 coverage usedevelop=True