Browse Source

opravy bad designu

pull/73/head
ticvac 3 days ago
parent
commit
c8dd54e8ba
  1. 16
      soustredeni/urls.py
  2. 15
      soustredeni/views.py

16
soustredeni/urls.py

@ -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'
), ),
path( path(
'fotogalerie/', 'fotogalerie/',

15
soustredeni/views.py

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

Loading…
Cancel
Save