Merge branch 'Kerl/fix_43_unpaid' into 'master'

Corrige la liste des impayés dans bda

La liste des gens n'ayant pas payé leurs places pour un tirage ne
contient plus les participants n'ayant pas eu de place.

Ajoute un compte des impayés dans le template.

Fixes #43 

See merge request !40
This commit is contained in:
Martin Pepin 2016-06-25 19:50:54 +02:00
commit 0e19653f46
2 changed files with 5 additions and 1 deletions

View file

@ -4,4 +4,5 @@
<h2>Impayés</h2> <h2>Impayés</h2>
<textarea style="width: 100%; height: 100px; margin-top: 10px;"> <textarea style="width: 100%; height: 100px; margin-top: 10px;">
{% for participant in unpaid %}{{ participant.user.email }}, {% endfor %}</textarea> {% for participant in unpaid %}{{ participant.user.email }}, {% endfor %}</textarea>
<h3>Total&nbsp: {{ unpaid|length }}</h3>
{% endblock %} {% endblock %}

View file

@ -5,6 +5,7 @@ from __future__ import division
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.db import models from django.db import models
from django.db.models import Count
from django.core import serializers from django.core import serializers
from django.forms.models import inlineformset_factory from django.forms.models import inlineformset_factory
import hashlib import hashlib
@ -331,7 +332,9 @@ class SpectacleListView(ListView):
@buro_required @buro_required
def unpaid(request, tirage_id): def unpaid(request, tirage_id):
tirage = get_object_or_404(Tirage, id=tirage_id) tirage = get_object_or_404(Tirage, id=tirage_id)
unpaid = tirage.participant_set.filter(paid=False).all() unpaid = tirage.participant_set \
.annotate(nb_attributions=Count('attribution')) \
.filter(paid=False, nb_attributions__gt=0).all()
return render(request, "bda-unpaid.html", {"unpaid": unpaid}) return render(request, "bda-unpaid.html", {"unpaid": unpaid})
@buro_required @buro_required