Compare commits

..

No commits in common. "be8c9810e4ef83a82aa4ccac06b9e9af269cb6c1" and "d55199d6ae357c5fcf7564f5126e34aac41f1407" have entirely different histories.

5 changed files with 23 additions and 32 deletions

View file

@ -54,7 +54,7 @@ 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.csrf_error'
CSRF_FAILURE_VIEW = 'various.views.csrf_error'
# Modules configuration

View file

@ -5,7 +5,7 @@ from django.contrib.staticfiles.finders import find
import csv
import various.views.generic
import various.views
from seminar.views import obalkyView
from .models import Soustredeni, Soustredeni_Ucastnici
@ -38,10 +38,7 @@ class KonkretniSoustredeniMixin:
self.soustredeni = get_object_or_404(Soustredeni, id=soustredeni_id)
class SoustredeniUcastniciBaseView(
KonkretniSoustredeniMixin,
various.views.generic.NeprazdnyListView,
):
class SoustredeniUcastniciBaseView(KonkretniSoustredeniMixin, various.views.NeprazdnyListView):
"""
Slouží jako ListView účastníků soustředění
+ háže inteligentní chybu při soustředění bez účastníků
@ -85,10 +82,7 @@ class SoustredeniUcastniciExportView(SoustredeniUcastniciBaseView):
return response
class SoustredeniStvrzenkyView(
various.views.generic.TeXResponseMixin,
SoustredeniUcastniciBaseView,
):
class SoustredeniStvrzenkyView(various.views.TeXResponseMixin, SoustredeniUcastniciBaseView):
template_name = 'soustredeni/stvrzenky.tex'
dalsi_potrebne_soubory = [find('images/logomm.pdf')]

View file

@ -1,19 +1,23 @@
"""
Stejně jako je `django.views.generic` jsou zde generické Views
a pár mixinů, které upravují chování Views.
"""
import http
import tempfile
import shutil
import subprocess
import tempfile
from pathlib import Path
from django.http import HttpResponse
from django.http import HttpResponseForbidden, HttpResponse
from django.shortcuts import render
from django.template.loader import render_to_string
from django.views import generic
from django.template.loader import render_to_string
def csrf_error(request, reason=""):
""" Jednoduchý „template view“ (třída to být nemůže) pro CSRF chyby """
return render(
request, 'various/403_csrf.html',
{"url": request.META.get("HTTP_REFERER", None), "reason": reason},
status=HttpResponseForbidden.status_code,
)
class NeprazdnyListView(generic.ListView):
@ -41,7 +45,9 @@ class NeprazdnyListView(generic.ListView):
return render(request, 'universal.html', {
'title': self.if_prazdny_title,
'text': self.if_prazdny_text,
}, status=http.HTTPStatus.NOT_FOUND)
},
status=http.HTTPStatus.NOT_FOUND,
)
return self.render(request, *args, **kwargs)
@ -75,3 +81,5 @@ class TeXResponseMixin:
with open(tempdir / "main.pdf", "rb") as pdffile:
response = HttpResponse(pdffile.read(), content_type='application/pdf', **response_kwargs)
return response

View file

@ -1,11 +0,0 @@
from django.http import HttpResponseForbidden
from django.shortcuts import render
def csrf_error(request, reason=""):
""" Jednoduchý „template view“ (třída to být nemůže) pro CSRF chyby """
return render(
request, 'various/403_csrf.html',
{"url": request.META.get("HTTP_REFERER", None), "reason": reason},
status=HttpResponseForbidden.status_code,
)