Update to Django 2.2

This commit is contained in:
Théophile Bastian 2020-06-16 12:00:24 +02:00
parent 8d8d26a14e
commit 0037f5f231
3 changed files with 44 additions and 57 deletions

View file

@ -1,19 +1,4 @@
"""bocal URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.urls import path, include
from django.contrib import admin
from django.contrib.auth.decorators import login_required
import django.contrib.auth.views as dj_auth_views
@ -31,24 +16,26 @@ import django_cas_ng.views
admin.site.login = login_required(forceReevalRhosts(admin.site.login))
cas_patterns = [
url(r'^login$', django_cas_ng.views.login, name='cas_ng_login'),
url(r'^logout$', django_cas_ng.views.logout, name='cas_ng_logout'),
url(r'^callback$', django_cas_ng.views.callback,
name='cas_ng_proxy_callback'),
path("login/", django_cas_ng.views.LoginView.as_view(), name="cas_ng_login"),
path("logout/", django_cas_ng.views.LogoutView.as_view(), name="cas_ng_logout"),
path(
"callback/",
django_cas_ng.views.CallbackView.as_view(),
name="cas_ng_proxy_callback",
),
]
accounts_patterns = [
url(r'^cas/', include(cas_patterns)),
url(r'^login$', auth_views.login, name='login'),
url(r'^logout$', auth_views.logout, name='logout'),
url(r'^password_login$', dj_auth_views.LoginView.as_view(),
name='password_login'),
path("cas/", include(cas_patterns)),
path("login/", auth_views.login, name="login"),
path("logout/", auth_views.logout, name="logout"),
path("password_login/", dj_auth_views.LoginView.as_view(), name="password_login"),
]
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^markdownx/', include(markdownx.urls)),
url(r'^api/', include(api.urls)),
url(r'^accounts/', include(accounts_patterns)),
url(r'^', include(mainsite.urls)),
path("admin/", admin.site.urls),
path("markdownx/", include(markdownx.urls)),
path("api/", include(api.urls)),
path("accounts/", include(accounts_patterns)),
path("", include(mainsite.urls)),
]

View file

@ -7,36 +7,36 @@ from urllib.parse import quote as urlquote
def login(req):
if req.user.is_authenticated():
return redirect('homepage')
if req.user.is_authenticated:
return redirect("homepage")
if req.method == 'GET':
if req.method == "GET":
reqDict = req.GET
elif req.method == 'POST':
elif req.method == "POST":
reqDict = req.POST
if 'next' in reqDict:
nextUrl = reqDict['next']
if "next" in reqDict:
nextUrl = reqDict["next"]
context = {
'pass_url': '{}?next={}'.format(
reverse('password_login'),
urlquote(nextUrl, safe='')),
'cas_url': '{}?next={}'.format(
reverse('cas_ng_login'),
urlquote(nextUrl, safe='')),
"pass_url": "{}?next={}".format(
reverse("password_login"), urlquote(nextUrl, safe="")
),
"cas_url": "{}?next={}".format(
reverse("cas_ng_login"), urlquote(nextUrl, safe="")
),
}
else:
context = {
'pass_url': reverse('password_login'),
'cas_url': reverse('cas_ng_login'),
"pass_url": reverse("password_login"),
"cas_url": reverse("cas_ng_login"),
}
return render(req, 'mainsite/login.html', context=context)
return render(req, "mainsite/login.html", context=context)
@login_required
def logout(req):
CAS_BACKEND_NAME = 'django_cas_ng.backends.CASBackend'
if req.session['_auth_user_backend'] != CAS_BACKEND_NAME:
CAS_BACKEND_NAME = "django_cas_ng.backends.CASBackend"
if req.session["_auth_user_backend"] != CAS_BACKEND_NAME:
auth_logout(req)
return redirect('homepage')
return redirect('cas_ng_logout')
return redirect("homepage")
return redirect("cas_ng_logout")

View file

@ -1,9 +1,9 @@
Django==1.11.5
django-cas-ng==3.5.8
django-markdownx==2.0.21
django-solo==1.1.2
Markdown==2.6.9
olefile==0.44
Pillow==4.2.1
Django==2.2
django-cas-ng==4.1.1
django-markdownx==3.0.1
django-solo==1.1.3
Markdown==3.2.2
olefile==0.46
Pillow==7.1.2
pytz==2017.2
lxml==4.1.0
lxml==4.5.1