verejny kontaktnicek #71

Merged
ticvac merged 10 commits from kontaktnicek_pro_vsecny into master 2024-11-12 21:15:25 +01:00
2 changed files with 17 additions and 16 deletions
Showing only changes of commit c8dd54e8ba - Show all commits

View file

@ -44,15 +44,15 @@ urlpatterns = [
org_required(views.SoustredeniAbstraktyView.as_view()), org_required(views.SoustredeniAbstraktyView.as_view()),
name='soustredeni_abstrakty' name='soustredeni_abstrakty'
), ),
path( path(
'kontaktnicek_pdf', 'kontaktnicek_pdf',
views.soustredeniKontaktnicekPdfView, views.soustredeniKontaktnicekPdfView,
name='soustredeni_kontaktnicek' name='soustredeni_kontaktnicek'
), ),
path( path(
'kontaktnicek_vcf', 'kontaktnicek_vcf',
views.soustredeniKontaktnicekVcfView, views.soustredeniKontaktnicekVcfView,
name='soustredeni_kontaktnicek' name='soustredeni_kontaktnicek'
), ),
zelvuska marked this conversation as resolved
Review

Tady je nějaké divné odsazení…

Tady je nějaké divné odsazení…
path( path(
'fotogalerie/', 'fotogalerie/',
@ -60,5 +60,5 @@ urlpatterns = [
), ),
] ]
) )
) )
] ]

View file

@ -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")