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