From 4f1828b7af2f40869cc3d78d3d66618d27108316 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 19 Dec 2019 01:30:48 +0100 Subject: [PATCH] =?UTF-8?q?P=C5=99ihla=C5=A1ovac=C3=AD=20a=20odhla=C5=A1ov?= =?UTF-8?q?ac=C3=AD=20a=20heslo-zapom=C3=ADnac=C3=AD=20views?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Templates většinou chybí. --- seminar/templates/seminar/login.html | 2 ++ seminar/templates/seminar/logout.html | 18 ++++++++++++++++ seminar/urls.py | 8 +++++-- seminar/views.py | 31 ++++++++++++++++++++++++++- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 seminar/templates/seminar/logout.html diff --git a/seminar/templates/seminar/login.html b/seminar/templates/seminar/login.html index eee1303c..6319ecc0 100644 --- a/seminar/templates/seminar/login.html +++ b/seminar/templates/seminar/login.html @@ -13,6 +13,8 @@ + {# Django si posílá jméno další stránky jako obsah formuláře a výchozí hodnota (mi přišlo, že) nejde změnit... #} + diff --git a/seminar/templates/seminar/logout.html b/seminar/templates/seminar/logout.html new file mode 100644 index 00000000..ab41a8c8 --- /dev/null +++ b/seminar/templates/seminar/logout.html @@ -0,0 +1,18 @@ +{% extends "seminar/zadani/base.html" %} +{% load staticfiles %} + + +{% block content %} +

+ {% block nadpis1a %}{% block nadpis1b %} + Odhlášení + {% endblock %}{% endblock %} +

+ +Byl jsi úspěšně odhlášen +{# Tohle by se asi mělo udělat přes kontext (title), ale kašlu na to, stejně je to jen jednojazyčná stránka #} + +{# TODO: odkaz na znovupřihlášení? #} + +{% endblock %} + diff --git a/seminar/urls.py b/seminar/urls.py index 213494f6..3d3bd1d5 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -103,10 +103,14 @@ urlpatterns = [ ), path('auth/prihlaska/',views.prihlaskaView, name='seminar_prihlaska'), path('auth/login/', views.LoginView.as_view(), name='login'), - path('auth/logout/', views.logoutView, name='logout'), + path('auth/logout/', views.LogoutView.as_view(), name='logout'), path('auth/resitel/', views.ResitelView.as_view(), name='seminar_resitel'), path('autocomplete/skola/',views.SkolaAutocomplete.as_view(), name='autocomplete_skola'), - path('auth/reset_password', views.resetPasswordView, name='reset_password'), + path('auth/reset_password/', views.PasswordResetView.as_view(), name='reset_password'), + path('auth/change_password/', views.PasswordChangeView.as_view(), name='change_password'), + path('auth/reset_password_done/', views.PasswordResetDoneView.as_view(), name='reset_password_done'), + path('auth/reset_password_confirm/', views.PasswordResetConfirmView.as_view(), name='reset_password_confirm'), + path('auth/reset_password_complete/', views.PasswordResetCompleteView.as_view(), name='reset_password_complete'), path('auth/resitel_edit', views.resitelEditView, name='seminar_resitel_edit'), path('', views.TitulniStranaView.as_view(), name='titulni_strana'), diff --git a/seminar/views.py b/seminar/views.py index ccbb2d00..66a65bbc 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404, render from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, JsonResponse -from django.urls import reverse +from django.urls import reverse,reverse_lazy from django.core.exceptions import PermissionDenied, ObjectDoesNotExist from django.views import generic from django.utils.translation import ugettext as _ @@ -1281,3 +1281,32 @@ class LoginView(auth_views.LoginView): ctx = super().get_context_data(**kwargs) ctx['next'] = reverse('titulni_strana') return ctx + +class LogoutView(auth_views.LogoutView): + # Jen vezmeme vestavěný a dáme mu vhodný template a přesměrovací URL + template_name = 'seminar/logout.html' + # Pavel: Vůbec nevím, proč to s _lazy funguje, ale bez toho to bylo rozbité. + next_page = reverse_lazy('titulni_strana') + +class PasswordResetView(auth_views.PasswordResetView): + #template_name = 'seminar/password_reset.html' + # TODO: vlastní email_template_name a subject_template_name a html_email_template_name + success_url = reverse_lazy('reset_password_done') + from_email = 'login@mam.mff.cuni.cz' + # TODO: přepsat User-a :-( + +class PasswordResetDoneView(auth_views.PasswordResetDoneView): + #template_name = 'seminar/password_reset_done.html' + pass + +class PasswordResetConfirmView(auth_views.PasswordResetConfirmView): + #template_name = 'seminar/password_confirm_done.html' + success_url = reverse_lazy('reset_password_complete') + +class PasswordResetCompleteView(auth_views.PasswordResetCompleteView): + #template_name = 'seminar/password_complete_done.html' + pass + +class PasswordChangeView(auth_views.PasswordChangeView): + #template_name = 'seminar/password_change.html' + success_url = reverse_lazy('titulni_strana')