Compare commits
No commits in common. "be8c9810e4ef83a82aa4ccac06b9e9af269cb6c1" and "d55199d6ae357c5fcf7564f5126e34aac41f1407" have entirely different histories.
be8c9810e4
...
d55199d6ae
5 changed files with 23 additions and 32 deletions
|
@ -54,7 +54,7 @@ SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||||
DOBA_ODHLASENI_PRI_ZASKRTNUTI_NEODHLASOVAT = 365 * 24 * 3600 # rok
|
DOBA_ODHLASENI_PRI_ZASKRTNUTI_NEODHLASOVAT = 365 * 24 * 3600 # rok
|
||||||
|
|
||||||
# View pro chybu s CSRF tokenem (např. se sušenkami)
|
# 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
|
# Modules configuration
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.contrib.staticfiles.finders import find
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
import various.views.generic
|
import various.views
|
||||||
from seminar.views import obalkyView
|
from seminar.views import obalkyView
|
||||||
|
|
||||||
from .models import Soustredeni, Soustredeni_Ucastnici
|
from .models import Soustredeni, Soustredeni_Ucastnici
|
||||||
|
@ -38,10 +38,7 @@ class KonkretniSoustredeniMixin:
|
||||||
self.soustredeni = get_object_or_404(Soustredeni, id=soustredeni_id)
|
self.soustredeni = get_object_or_404(Soustredeni, id=soustredeni_id)
|
||||||
|
|
||||||
|
|
||||||
class SoustredeniUcastniciBaseView(
|
class SoustredeniUcastniciBaseView(KonkretniSoustredeniMixin, various.views.NeprazdnyListView):
|
||||||
KonkretniSoustredeniMixin,
|
|
||||||
various.views.generic.NeprazdnyListView,
|
|
||||||
):
|
|
||||||
"""
|
"""
|
||||||
Slouží jako ListView účastníků soustředění
|
Slouží jako ListView účastníků soustředění
|
||||||
+ háže inteligentní chybu při soustředění bez účastníků
|
+ háže inteligentní chybu při soustředění bez účastníků
|
||||||
|
@ -85,10 +82,7 @@ class SoustredeniUcastniciExportView(SoustredeniUcastniciBaseView):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
class SoustredeniStvrzenkyView(
|
class SoustredeniStvrzenkyView(various.views.TeXResponseMixin, SoustredeniUcastniciBaseView):
|
||||||
various.views.generic.TeXResponseMixin,
|
|
||||||
SoustredeniUcastniciBaseView,
|
|
||||||
):
|
|
||||||
template_name = 'soustredeni/stvrzenky.tex'
|
template_name = 'soustredeni/stvrzenky.tex'
|
||||||
dalsi_potrebne_soubory = [find('images/logomm.pdf')]
|
dalsi_potrebne_soubory = [find('images/logomm.pdf')]
|
||||||
|
|
||||||
|
|
|
@ -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 http
|
||||||
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponseForbidden, HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.template.loader import render_to_string
|
|
||||||
from django.views import generic
|
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):
|
class NeprazdnyListView(generic.ListView):
|
||||||
|
@ -41,7 +45,9 @@ class NeprazdnyListView(generic.ListView):
|
||||||
return render(request, 'universal.html', {
|
return render(request, 'universal.html', {
|
||||||
'title': self.if_prazdny_title,
|
'title': self.if_prazdny_title,
|
||||||
'text': self.if_prazdny_text,
|
'text': self.if_prazdny_text,
|
||||||
}, status=http.HTTPStatus.NOT_FOUND)
|
},
|
||||||
|
status=http.HTTPStatus.NOT_FOUND,
|
||||||
|
)
|
||||||
|
|
||||||
return self.render(request, *args, **kwargs)
|
return self.render(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@ -75,3 +81,5 @@ class TeXResponseMixin:
|
||||||
with open(tempdir / "main.pdf", "rb") as pdffile:
|
with open(tempdir / "main.pdf", "rb") as pdffile:
|
||||||
response = HttpResponse(pdffile.read(), content_type='application/pdf', **response_kwargs)
|
response = HttpResponse(pdffile.read(), content_type='application/pdf', **response_kwargs)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
|
@ -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,
|
|
||||||
)
|
|
Loading…
Reference in a new issue