From 7686d33dff38348eea98e4b70233d59b9a068f94 Mon Sep 17 00:00:00 2001 From: ludo Date: Sun, 12 Jun 2016 18:00:26 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20de=20l'ajout=20de=20participants?= =?UTF-8?q?=20=C3=A0=20un=20spectacle=20;=20cr=C3=A9ation=20d'url=20et=20g?= =?UTF-8?q?estion=20de=20formulaire=20(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/urls.py | 3 +++ bda/views.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bda/urls.py b/bda/urls.py index d3f4fe2f..8cd94d17 100644 --- a/bda/urls.py +++ b/bda/urls.py @@ -32,4 +32,7 @@ urlpatterns = patterns('', url(r'spectacles/unpaid/(?P\d+)$', "bda.views.unpaid", name="bda-unpaid"), + url(r'spectacles/add-attrib/(?P\d+)/(?P\d+)$', + 'bda.views.add_attrib', + name='bda-add-attrib'), ) diff --git a/bda/views.py b/bda/views.py index c79a5483..9c052c84 100644 --- a/bda/views.py +++ b/bda/views.py @@ -12,6 +12,8 @@ import hashlib from django.core.mail import send_mail from django.utils import timezone from django.views.generic.list import ListView +from django.http import HttpResponseRedirect +from django.core.urlresolvers import reverse from datetime import timedelta import time @@ -305,7 +307,18 @@ def spectacle(request, tirage_id, spectacle_id): return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants.values()}) - +@buro_required +def add_attrib(request, tirage_id, spectacle_id): + tirage = get_object_or_404(Tirage, id=tirage_id) + spectacle = get_object_or_404(Spectacle, id = spectacle_id, tirage=tirage) + # TODO : erreur + part= tirage.participant_set.get(user__username=request.POST['clipper']) + attrib = Attribution(participant=part, spectacle=spectacle, given=request.POST['given']) + attrib.save() + if request.POST['nb_places']==2: + attrib.save() + return HttpResponseRedirect(reverse('bda-spectacle', args=(tirage_id, spectacle_id,))) + class SpectacleListView(ListView): model = Spectacle template_name = 'spectacle_list.html'