From 1b755ad1f753c9e1a847e2acf6daa78449943a78 Mon Sep 17 00:00:00 2001 From: ticvac Date: Tue, 12 Nov 2024 20:37:14 +0100 Subject: [PATCH] deduplikace listu --- soustredeni/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/soustredeni/views.py b/soustredeni/views.py index cd326002..83ddee19 100644 --- a/soustredeni/views.py +++ b/soustredeni/views.py @@ -121,9 +121,6 @@ def soustredeniKontaktnicekView(request, soustredeni, typ): # nebyl jsi tam, nebo nejsi org if (not request.user in [u.osoba.user for u in soustredeni.ucastnici.all()]) and not request.user.je_org: raise PermissionDenied() - # není k dispozici - if (not soustredeni.kontaktnicek_pdf and typ == "pdf") or (not soustredeni.kontaktnicek_vcf and typ == "vcf"): - raise Http404() kontaktnicky = { 'pdf': (soustredeni.kontaktnicek_pdf, 'applcation/pdf', 'rb'), @@ -134,6 +131,10 @@ def soustredeniKontaktnicekView(request, soustredeni, typ): field, mime, otevreni = kontaktnicky[typ] except KeyError as e: raise ValueError("Neznámý typ kontaktníčku") from e + + # není k dispozici + if not field: + raise Http404() with open(field.path, otevreni) as kontaktnicek: response = HttpResponse(kontaktnicek.read(), content_type=mime)