Début de l'ajout de participants à un spectacle ; création d'url et gestion de formulaire (WIP)

This commit is contained in:
ludo 2016-06-12 18:00:26 +02:00
parent 185c7b5ca4
commit 7686d33dff
2 changed files with 17 additions and 1 deletions

View file

@ -32,4 +32,7 @@ urlpatterns = patterns('',
url(r'spectacles/unpaid/(?P<tirage_id>\d+)$', url(r'spectacles/unpaid/(?P<tirage_id>\d+)$',
"bda.views.unpaid", "bda.views.unpaid",
name="bda-unpaid"), name="bda-unpaid"),
url(r'spectacles/add-attrib/(?P<tirage_id>\d+)/(?P<spectacle_id>\d+)$',
'bda.views.add_attrib',
name='bda-add-attrib'),
) )

View file

@ -12,6 +12,8 @@ import hashlib
from django.core.mail import send_mail from django.core.mail import send_mail
from django.utils import timezone from django.utils import timezone
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from datetime import timedelta from datetime import timedelta
import time import time
@ -305,6 +307,17 @@ def spectacle(request, tirage_id, spectacle_id):
return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants.values()}) 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): class SpectacleListView(ListView):
model = Spectacle model = Spectacle