Browse Source

deduplikace listu

pull/71/head
ticvac 2 weeks 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
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'),
@ -135,6 +132,10 @@ def soustredeniKontaktnicekView(request, soustredeni, 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)
response['Content-Disposition'] = 'attachment; filename="kontaktnicek.{}"'.format(typ)

Loading…
Cancel
Save