Browse Source

Přihlašovací a odhlašovací a heslo-zapomínací views

Templates většinou chybí.
export_seznamu_prednasek
Pavel 'LEdoian' Turinsky 5 years ago
parent
commit
4f1828b7af
  1. 2
      seminar/templates/seminar/login.html
  2. 18
      seminar/templates/seminar/logout.html
  3. 8
      seminar/urls.py
  4. 31
      seminar/views.py

2
seminar/templates/seminar/login.html

@ -13,6 +13,8 @@
<ul class="form">
{{ form.as_ul }}
</ul>
{# 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... #}
<input type="hidden" name='next' value="{{ next }}">
<input type="submit" value="Přihlásit">
</form>

18
seminar/templates/seminar/logout.html

@ -0,0 +1,18 @@
{% extends "seminar/zadani/base.html" %}
{% load staticfiles %}
{% block content %}
<h1>
{% block nadpis1a %}{% block nadpis1b %}
Odhlášení
{% endblock %}{% endblock %}
</h1>
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 %}

8
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'),

31
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')

Loading…
Cancel
Save