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'