Update to Django 2.2
This commit is contained in:
parent
8d8d26a14e
commit
0037f5f231
3 changed files with 44 additions and 57 deletions
|
@ -1,19 +1,4 @@
|
||||||
"""bocal URL Configuration
|
from django.urls import path, include
|
||||||
|
|
||||||
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.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
import django.contrib.auth.views as dj_auth_views
|
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))
|
admin.site.login = login_required(forceReevalRhosts(admin.site.login))
|
||||||
|
|
||||||
cas_patterns = [
|
cas_patterns = [
|
||||||
url(r'^login$', django_cas_ng.views.login, name='cas_ng_login'),
|
path("login/", django_cas_ng.views.LoginView.as_view(), name="cas_ng_login"),
|
||||||
url(r'^logout$', django_cas_ng.views.logout, name='cas_ng_logout'),
|
path("logout/", django_cas_ng.views.LogoutView.as_view(), name="cas_ng_logout"),
|
||||||
url(r'^callback$', django_cas_ng.views.callback,
|
path(
|
||||||
name='cas_ng_proxy_callback'),
|
"callback/",
|
||||||
|
django_cas_ng.views.CallbackView.as_view(),
|
||||||
|
name="cas_ng_proxy_callback",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
accounts_patterns = [
|
accounts_patterns = [
|
||||||
url(r'^cas/', include(cas_patterns)),
|
path("cas/", include(cas_patterns)),
|
||||||
url(r'^login$', auth_views.login, name='login'),
|
path("login/", auth_views.login, name="login"),
|
||||||
url(r'^logout$', auth_views.logout, name='logout'),
|
path("logout/", auth_views.logout, name="logout"),
|
||||||
url(r'^password_login$', dj_auth_views.LoginView.as_view(),
|
path("password_login/", dj_auth_views.LoginView.as_view(), name="password_login"),
|
||||||
name='password_login'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^admin/', admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
url(r'^markdownx/', include(markdownx.urls)),
|
path("markdownx/", include(markdownx.urls)),
|
||||||
url(r'^api/', include(api.urls)),
|
path("api/", include(api.urls)),
|
||||||
url(r'^accounts/', include(accounts_patterns)),
|
path("accounts/", include(accounts_patterns)),
|
||||||
url(r'^', include(mainsite.urls)),
|
path("", include(mainsite.urls)),
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,36 +7,36 @@ from urllib.parse import quote as urlquote
|
||||||
|
|
||||||
|
|
||||||
def login(req):
|
def login(req):
|
||||||
if req.user.is_authenticated():
|
if req.user.is_authenticated:
|
||||||
return redirect('homepage')
|
return redirect("homepage")
|
||||||
|
|
||||||
if req.method == 'GET':
|
if req.method == "GET":
|
||||||
reqDict = req.GET
|
reqDict = req.GET
|
||||||
elif req.method == 'POST':
|
elif req.method == "POST":
|
||||||
reqDict = req.POST
|
reqDict = req.POST
|
||||||
if 'next' in reqDict:
|
if "next" in reqDict:
|
||||||
nextUrl = reqDict['next']
|
nextUrl = reqDict["next"]
|
||||||
context = {
|
context = {
|
||||||
'pass_url': '{}?next={}'.format(
|
"pass_url": "{}?next={}".format(
|
||||||
reverse('password_login'),
|
reverse("password_login"), urlquote(nextUrl, safe="")
|
||||||
urlquote(nextUrl, safe='')),
|
),
|
||||||
'cas_url': '{}?next={}'.format(
|
"cas_url": "{}?next={}".format(
|
||||||
reverse('cas_ng_login'),
|
reverse("cas_ng_login"), urlquote(nextUrl, safe="")
|
||||||
urlquote(nextUrl, safe='')),
|
),
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
context = {
|
context = {
|
||||||
'pass_url': reverse('password_login'),
|
"pass_url": reverse("password_login"),
|
||||||
'cas_url': reverse('cas_ng_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
|
@login_required
|
||||||
def logout(req):
|
def logout(req):
|
||||||
CAS_BACKEND_NAME = 'django_cas_ng.backends.CASBackend'
|
CAS_BACKEND_NAME = "django_cas_ng.backends.CASBackend"
|
||||||
if req.session['_auth_user_backend'] != CAS_BACKEND_NAME:
|
if req.session["_auth_user_backend"] != CAS_BACKEND_NAME:
|
||||||
auth_logout(req)
|
auth_logout(req)
|
||||||
return redirect('homepage')
|
return redirect("homepage")
|
||||||
return redirect('cas_ng_logout')
|
return redirect("cas_ng_logout")
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
Django==1.11.5
|
Django==2.2
|
||||||
django-cas-ng==3.5.8
|
django-cas-ng==4.1.1
|
||||||
django-markdownx==2.0.21
|
django-markdownx==3.0.1
|
||||||
django-solo==1.1.2
|
django-solo==1.1.3
|
||||||
Markdown==2.6.9
|
Markdown==3.2.2
|
||||||
olefile==0.44
|
olefile==0.46
|
||||||
Pillow==4.2.1
|
Pillow==7.1.2
|
||||||
pytz==2017.2
|
pytz==2017.2
|
||||||
lxml==4.1.0
|
lxml==4.5.1
|
||||||
|
|
Loading…
Reference in a new issue