diff --git a/seminar/templates/seminar/login.html b/seminar/templates/seminar/login.html index 88cd364f..eee1303c 100644 --- a/seminar/templates/seminar/login.html +++ b/seminar/templates/seminar/login.html @@ -8,19 +8,10 @@ Přihlášení {% endblock %}{% endblock %} -{% if login_error %} -{{login_error}} -{% endif %}
{% csrf_token %} - {{form.non_field_errors}}
    -
  • - {% include "seminar/prihlaska_field.html" with field=form.username %} -
  • -
  • - {% include "seminar/prihlaska_field.html" with field=form.password %} -
  • + {{ form.as_ul }}
diff --git a/seminar/urls.py b/seminar/urls.py index 9d2c158a..5f534020 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -99,7 +99,7 @@ urlpatterns = [ name='seminar_tex_upload' ), path('auth/prihlaska/',views.prihlaskaView, name='seminar_prihlaska'), - path('auth/login/', views.loginView, name='login'), + path('auth/login/', views.LoginView.as_view(), name='login'), path('auth/logout/', views.logoutView, name='logout'), path('auth/resitel/', views.ResitelView.as_view(), name='seminar_resitel'), path('autocomplete/skola/',views.SkolaAutocomplete.as_view(), name='autocomplete_skola'), diff --git a/seminar/views.py b/seminar/views.py index bb580c08..46571927 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -10,6 +10,7 @@ from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect from django.db.models import Q from django.views.decorators.csrf import ensure_csrf_cookie from django.contrib.auth import authenticate, login, get_user_model, logout +from django.contrib.auth import views as auth_views from django.contrib.auth.models import User from django.contrib.auth.mixins import LoginRequiredMixin from django.db import transaction @@ -1154,3 +1155,14 @@ class SkolaAutocomplete(autocomplete.Select2QuerySetView): # Q(user__last_name__isstartswith=query)) # # return qs + +# FIXME: Tohle asi vlastně vůbec nepatří do aplikace 'seminar' +class LoginView(auth_views.LoginView): + # Jen vezmeme vestavěný a dáme mu vhodný template a přesměrovací URL + template_name = 'seminar/login.html' + + # Přesměrovací URL má být v kontextu: + def get_context_data(self, **kwargs): + ctx = super().get_context_data(**kwargs) + ctx['next'] = reverse('titulni_strana') + return ctx