|
@ -2,6 +2,7 @@ from django.shortcuts import get_object_or_404, render |
|
|
from django.http import HttpResponse |
|
|
from django.http import HttpResponse |
|
|
from django.views import generic |
|
|
from django.views import generic |
|
|
from django.contrib.staticfiles.finders import find |
|
|
from django.contrib.staticfiles.finders import find |
|
|
|
|
|
from django.http import Http404 |
|
|
|
|
|
|
|
|
import csv |
|
|
import csv |
|
|
import tempfile |
|
|
import tempfile |
|
@ -118,12 +119,12 @@ def soustredeniKontaktnicekView(request, soustredeni, typ): |
|
|
soustredeni = get_object_or_404(Soustredeni, id=soustredeni) |
|
|
soustredeni = get_object_or_404(Soustredeni, id=soustredeni) |
|
|
|
|
|
|
|
|
if (not request.user in [u.osoba.user for u in soustredeni.ucastnici.all()]): |
|
|
if (not request.user in [u.osoba.user for u in soustredeni.ucastnici.all()]): |
|
|
if not request.user.je_org: |
|
|
if not request.user.je_org: # nebyl jsi tam, nebo nejsi org |
|
|
return HttpResponse("Nebyl jsi tam nebo nejsi org") |
|
|
raise Http404() |
|
|
if not soustredeni.kontaktnicek_pdf and typ == "pdf": |
|
|
if not soustredeni.kontaktnicek_pdf and typ == "pdf": # není k dispozici |
|
|
return HttpResponse("Kontaktníček není k dispozici") |
|
|
raise Http404() |
|
|
elif not soustredeni.kontaktnicek_vcf and typ == "vcf": |
|
|
elif not soustredeni.kontaktnicek_vcf and typ == "vcf": # není k dispozici |
|
|
return HttpResponse("Kontaktníček není k dispozici") |
|
|
raise Http404() |
|
|
|
|
|
|
|
|
if typ == "pdf": |
|
|
if typ == "pdf": |
|
|
with open(soustredeni.kontaktnicek_pdf.path, 'rb') as pdf: |
|
|
with open(soustredeni.kontaktnicek_pdf.path, 'rb') as pdf: |
|
@ -134,4 +135,4 @@ def soustredeniKontaktnicekView(request, soustredeni, typ): |
|
|
response = HttpResponse(vcf.read(), content_type='text/vcard') |
|
|
response = HttpResponse(vcf.read(), content_type='text/vcard') |
|
|
return response |
|
|
return response |
|
|
else: |
|
|
else: |
|
|
return HttpResponse("Neplatný typ kontaktníčku") |
|
|
raise ValueError("Nepodporovaný typ kontaktníčku") |
|
|