diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html index ed3767a3..9669c939 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda-participants.html @@ -3,7 +3,7 @@ {% block realcontent %}

{{ spectacle }}

{% for message in messages %} -

{{ message }}

+

{{ message }}

{% endfor %} @@ -18,8 +18,13 @@ {% for participant in participants %} + + {% csrf_token %} - + - + + {% endfor %} @@ -48,7 +60,7 @@ - +
{{participant.name}}{{participant.username}}{{participant.username}} + {{participant.nb_places}} place{{participant.nb_places|pluralize}} {{participant.email}} @@ -28,11 +33,18 @@ -
- {% if participant.given %}Oui{% else %}Non{%endif%} +
+ {% if participant.given == participant.nb_places %}Oui + {% elif participant.given == 0 %}Non + {% else %}{{participant.given}}/{{participant.nb_places}} + {%endif%}

diff --git a/bda/urls.py b/bda/urls.py index 8cd94d17..1617d36b 100644 --- a/bda/urls.py +++ b/bda/urls.py @@ -35,4 +35,7 @@ urlpatterns = patterns('', url(r'spectacles/add-attrib/(?P\d+)/(?P\d+)$', 'bda.views.add_attrib', name='bda-add-attrib'), + url(r'spectacles/del-attrib/(?P\d+)/(?P\d+)$', + 'bda.views.del_attrib', + name='bda-del-attrib'), ) diff --git a/bda/views.py b/bda/views.py index c8e250f1..3f446310 100644 --- a/bda/views.py +++ b/bda/views.py @@ -15,6 +15,7 @@ from django.views.generic.list import ListView from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse from django.contrib import messages +from django.views.decorators.http import require_POST from datetime import timedelta import time @@ -303,11 +304,12 @@ def spectacle(request, tirage_id, spectacle_id): 'name': participant.user.get_full_name, 'username':participant.user.username, 'email':participant.user.email, - 'given':attrib.given, + 'given':int(attrib.given), 'paid':participant.paid, 'nb_places':1} if participant.id in participants: - participants[participant.id]['nb_places'] = 2 + participants[participant.id]['nb_places'] += 1 + participants[participant.id]['given'] += attrib.given else: participants[participant.id] = participant_info @@ -317,9 +319,10 @@ def spectacle(request, tirage_id, spectacle_id): {"spectacle": spectacle, "participants": participants_info}) @buro_required +@require_POST 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) + spectacle = get_object_or_404(Spectacle, id=spectacle_id, tirage=tirage) try: part=tirage.participant_set.get(user__username=request.POST['username']) except Participant.DoesNotExist: @@ -328,14 +331,6 @@ def add_attrib(request, tirage_id, spectacle_id): return HttpResponseRedirect(reverse('bda-spectacle', args=(tirage_id, spectacle_id,))) - places_owned = len(spectacle.attribues.filter(participant=part)) - - if int(request.POST['nb_places'])+places_owned > 2: - messages.add_message(request, messages.ERROR, - "Erreur: on ne peut pas avoir plus de deux places") - return HttpResponseRedirect(reverse('bda-spectacle', - args=(tirage_id, spectacle_id,))) - attrib = Attribution(participant=part, spectacle=spectacle, given=('given' in request.POST)) attrib.save() @@ -345,6 +340,20 @@ def add_attrib(request, tirage_id, spectacle_id): "Attribution réussie !") return HttpResponseRedirect(reverse('bda-spectacle', args=(tirage_id, spectacle_id,))) + +@buro_required +@require_POST +def del_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) + part = tirage.participant_set.get(user__username=request.POST['username']) + spectacle.attribues.filter(participant=part).delete() + + + messages.add_message(request, messages.SUCCESS, + "Attribution(s) supprimée(s) !") + return HttpResponseRedirect(reverse('bda-spectacle', + args=(tirage_id, spectacle_id,))) class SpectacleListView(ListView): model = Spectacle diff --git a/gestioncof/static/css/cof.css b/gestioncof/static/css/cof.css index d59e6ded..ed7363c9 100644 --- a/gestioncof/static/css/cof.css +++ b/gestioncof/static/css/cof.css @@ -601,6 +601,11 @@ pre code { .etat-bda tr:nth-child(even) {background: #CCC} +#bda-part-button { + border:none; + background-color:#eee +} + .greenratio { background-color: #3F3; border: 5px solid #ccc;