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
|
# 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…
Reference in a new issue