Browse Source

deduplikace listu

pull/71/head
ticvac 1 week ago
parent
commit
1b755ad1f7
  1. 7
      soustredeni/views.py

7
soustredeni/views.py

@ -121,9 +121,6 @@ def soustredeniKontaktnicekView(request, soustredeni, typ):
# nebyl jsi tam, nebo nejsi org # 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: if (not request.user in [u.osoba.user for u in soustredeni.ucastnici.all()]) and not request.user.je_org:
raise PermissionDenied() raise PermissionDenied()
# není k dispozici
if (not soustredeni.kontaktnicek_pdf and typ == "pdf") or (not soustredeni.kontaktnicek_vcf and typ == "vcf"):
raise Http404()
kontaktnicky = { kontaktnicky = {
'pdf': (soustredeni.kontaktnicek_pdf, 'applcation/pdf', 'rb'), 'pdf': (soustredeni.kontaktnicek_pdf, 'applcation/pdf', 'rb'),
@ -134,6 +131,10 @@ def soustredeniKontaktnicekView(request, soustredeni, typ):
field, mime, otevreni = kontaktnicky[typ] field, mime, otevreni = kontaktnicky[typ]
except KeyError as e: except KeyError as e:
raise ValueError("Neznámý typ kontaktníčku") from 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: with open(field.path, otevreni) as kontaktnicek:
response = HttpResponse(kontaktnicek.read(), content_type=mime) response = HttpResponse(kontaktnicek.read(), content_type=mime)

Loading…
Cancel
Save