diff --git a/soustredeni/views.py b/soustredeni/views.py index 899ee7f9..f150b6b8 100644 --- a/soustredeni/views.py +++ b/soustredeni/views.py @@ -9,6 +9,7 @@ import tempfile import shutil import subprocess from pathlib import Path +import http from seminar.views import obalkyView @@ -76,6 +77,14 @@ def soustredeniUcastniciExportView(request, soustredeni): def soustredeniStvrzenkyView(request, soustredeni): soustredeni = get_object_or_404(Soustredeni, id=soustredeni) ucastnici = Resitel.objects.filter(soustredeni=soustredeni) + if ucastnici.count() == 0: + return HttpResponse( + render(request, 'universal.html', { + 'title': 'Není pro koho vyrobit stvrzenky.', + 'text': 'Právě ses pokusil/a vygenerovat stvrzenky pro prázdnou množinu lidí. Můžeš to zkusit změnit, případně se zeptej webařů :-)', + }), + status=http.HTTPStatus.NOT_FOUND, + ) castka = Nastaveni.get_solo().cena_sous tex = render(request, 'soustredeni/stvrzenky.tex', {'ucastnici': ucastnici, 'soustredeni': soustredeni, 'castka': castka}).content