verejny kontaktnicek #71
1 changed files with 4 additions and 3 deletions
|
@ -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…
Reference in a new issue