From bb127832dc418a5c793dd1eac12440cd6a5457f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 9 Oct 2023 21:11:12 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Oprava=20=E2=80=9En=C3=A1zvu=20z=C3=A1lo?= =?UTF-8?q?=C5=BEky=E2=80=9C=20p=C5=99i=20Ojojojojoj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/templates/500.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mamweb/templates/500.html b/mamweb/templates/500.html index 7fc267fe..67085a8f 100644 --- a/mamweb/templates/500.html +++ b/mamweb/templates/500.html @@ -4,7 +4,9 @@ {% block errorheading %}
{# Meníčko nedostaneme, protože dostáváme prázdný kontext. Tak alespoň ať se O-JO-JO-JO-JOJ neschovává pod ním #} + {% block nadpis1a %} O-jo-jo-jo-joj + {% endblock %} {% endblock %} {% block errortext %} -- 2.39.5 From 60346d68390bb4c5f0f7b4d01989a2ee7cb43b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 9 Oct 2023 21:50:50 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Str=C3=A1nka=20pro=20CSRF=20chybu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/settings_common.py | 3 + various/static/various/img/zere_kostku.svg | 87 ++++++++++++++++++++++ various/templates/various/403_csrf.html | 19 +++++ various/views.py | 7 ++ 4 files changed, 116 insertions(+) create mode 100644 various/static/various/img/zere_kostku.svg create mode 100644 various/templates/various/403_csrf.html diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 03724d3d..36b39296 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -54,6 +54,9 @@ LOGIN_REDIRECT_URL = 'profil' SESSION_EXPIRE_AT_BROWSER_CLOSE = True DOBA_ODHLASENI_PRI_ZASKRTNUTI_NEODHLASOVAT = 365 * 24 * 3600 # rok +# View pro chybu s CSRF tokenem (např. se sušenkami) +CSRF_FAILURE_VIEW = 'various.views.csrf_error' + # Modules configuration AUTHENTICATION_BACKENDS = ( diff --git a/various/static/various/img/zere_kostku.svg b/various/static/various/img/zere_kostku.svg new file mode 100644 index 00000000..bac31662 --- /dev/null +++ b/various/static/various/img/zere_kostku.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + diff --git a/various/templates/various/403_csrf.html b/various/templates/various/403_csrf.html new file mode 100644 index 00000000..ff2f0cf9 --- /dev/null +++ b/various/templates/various/403_csrf.html @@ -0,0 +1,19 @@ +{#{% extends "error_base.html" %} Z toho nedědíme, protože se nemá přecházet na titulní stránku. #} +{% extends "base.html" %} + +{% load static %} + +{% block content %} + +

{% block nadpis1a %}O-jo-jo-jo-joj{% endblock nadpis1a %}

+ +

+ Problém se sušenkami či něčím podobným. Zkuste to prosím znovu: {{ url }}. Případně můžete přejít na titulní stránku. +

+ +

Pokud problém přetrvává obraťte se na nás přes e-mail: mailto:mam@matfyz.cz a pošlete nám následující popis chyby: {{ reason }}

+ + + + +{% endblock %} diff --git a/various/views.py b/various/views.py index 91ea44a2..3e5e1a5a 100644 --- a/various/views.py +++ b/various/views.py @@ -1,3 +1,10 @@ from django.shortcuts import render # Create your views here. + + +def csrf_error(request, reason): + return render( + request, 'various/403_csrf.html', + {"url": request.META["HTTP_REFERER"], "reason": reason}, + ) -- 2.39.5 From 29b327120049d0bee64f220443939a68ebae7f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 9 Oct 2023 22:02:05 +0200 Subject: [PATCH 3/5] =?UTF-8?q?CSRF=20chyba=20m=C3=A1=20vr=C3=A1tit=20403?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- various/views.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/various/views.py b/various/views.py index 3e5e1a5a..9bb6b109 100644 --- a/various/views.py +++ b/various/views.py @@ -1,3 +1,4 @@ +from django.http import HttpResponseForbidden from django.shortcuts import render # Create your views here. @@ -7,4 +8,5 @@ def csrf_error(request, reason): return render( request, 'various/403_csrf.html', {"url": request.META["HTTP_REFERER"], "reason": reason}, + status=HttpResponseForbidden.status_code, ) -- 2.39.5 From 0e24c1d9add98d95533d8884d5a23be7af72d10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 9 Oct 2023 22:04:01 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Koment=C3=A1=C5=99=20k=20CSRF=20chyb=C3=A1m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- various/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/various/views.py b/various/views.py index 9bb6b109..b5808f19 100644 --- a/various/views.py +++ b/various/views.py @@ -5,6 +5,7 @@ from django.shortcuts import render def csrf_error(request, reason): + """ Jednoduchý „template_view“ (třída to být nesmůže) pro CSRF chyby """ return render( request, 'various/403_csrf.html', {"url": request.META["HTTP_REFERER"], "reason": reason}, -- 2.39.5 From 68d51a0bf1d02b349141ba282d61614e5d37d8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 9 Oct 2023 22:14:27 +0200 Subject: [PATCH 5/5] =?UTF-8?q?P=C5=99eklep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- various/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/various/views.py b/various/views.py index b5808f19..7bc3fccd 100644 --- a/various/views.py +++ b/various/views.py @@ -5,7 +5,7 @@ from django.shortcuts import render def csrf_error(request, reason): - """ Jednoduchý „template_view“ (třída to být nesmůže) pro CSRF chyby """ + """ Jednoduchý „template_view“ (třída to být nemůže) pro CSRF chyby """ return render( request, 'various/403_csrf.html', {"url": request.META["HTTP_REFERER"], "reason": reason}, -- 2.39.5