From c8dd54e8ba330cd55d6d96528bc20b518ff61435 Mon Sep 17 00:00:00 2001 From: ticvac Date: Tue, 12 Nov 2024 18:37:21 +0100 Subject: [PATCH] opravy bad designu --- soustredeni/urls.py | 18 +++++++++--------- soustredeni/views.py | 15 ++++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/soustredeni/urls.py b/soustredeni/urls.py index a194218c..af88e456 100644 --- a/soustredeni/urls.py +++ b/soustredeni/urls.py @@ -44,15 +44,15 @@ urlpatterns = [ org_required(views.SoustredeniAbstraktyView.as_view()), name='soustredeni_abstrakty' ), - path( - 'kontaktnicek_pdf', - views.soustredeniKontaktnicekPdfView, - name='soustredeni_kontaktnicek' + path( + 'kontaktnicek_pdf', + views.soustredeniKontaktnicekPdfView, + name='soustredeni_kontaktnicek' ), - path( - 'kontaktnicek_vcf', - views.soustredeniKontaktnicekVcfView, - name='soustredeni_kontaktnicek' + path( + 'kontaktnicek_vcf', + views.soustredeniKontaktnicekVcfView, + name='soustredeni_kontaktnicek' ), path( 'fotogalerie/', @@ -60,5 +60,5 @@ urlpatterns = [ ), ] ) - ) + ) ] diff --git a/soustredeni/views.py b/soustredeni/views.py index b0145ff0..615ba10d 100644 --- a/soustredeni/views.py +++ b/soustredeni/views.py @@ -2,6 +2,7 @@ from django.shortcuts import get_object_or_404, render from django.http import HttpResponse from django.views import generic from django.contrib.staticfiles.finders import find +from django.http import Http404 import csv import tempfile @@ -118,12 +119,12 @@ def soustredeniKontaktnicekView(request, soustredeni, typ): 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.je_org: - return HttpResponse("Nebyl jsi tam nebo nejsi org") - if not soustredeni.kontaktnicek_pdf and typ == "pdf": - return HttpResponse("Kontaktníček není k dispozici") - elif not soustredeni.kontaktnicek_vcf and typ == "vcf": - return HttpResponse("Kontaktníček není k dispozici") + if not request.user.je_org: # nebyl jsi tam, nebo nejsi org + raise Http404() + if not soustredeni.kontaktnicek_pdf and typ == "pdf": # není k dispozici + raise Http404() + elif not soustredeni.kontaktnicek_vcf and typ == "vcf": # není k dispozici + raise Http404() if typ == "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') return response else: - return HttpResponse("Neplatný typ kontaktníčku") \ No newline at end of file + raise ValueError("Nepodporovaný typ kontaktníčku")