From 2b43db8a79b916d10311ac8d7907402ec252c74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 17 Jun 2016 02:05:05 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Corrige=20la=20liste=20des=20impay=C3=A9s?= =?UTF-8?q?=20dans=20bda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La liste des gens n'ayant pas payé leur 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 --- bda/templates/bda-unpaid.html | 1 + bda/views.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bda/templates/bda-unpaid.html b/bda/templates/bda-unpaid.html index 5596dd82..df30cfd3 100644 --- a/bda/templates/bda-unpaid.html +++ b/bda/templates/bda-unpaid.html @@ -4,4 +4,5 @@

Impayés

+

Total : {{ unpaid|length }}

{% endblock %} diff --git a/bda/views.py b/bda/views.py index fd0a0cdc..9b0323ce 100644 --- a/bda/views.py +++ b/bda/views.py @@ -330,7 +330,8 @@ class SpectacleListView(ListView): def unpaid(request, tirage_id): tirage = get_object_or_404(Tirage, id=tirage_id) unpaid = tirage.participant_set.filter(paid=False).all() - return render(request, "bda-unpaid.html", {"unpaid": unpaid}) + really_unpaid = [part for part in unpaid if part.attribution_set.all()] + return render(request, "bda-unpaid.html", {"unpaid": really_unpaid}) @buro_required def liste_spectacles_ics(request, tirage_id): From fc9805658210741260a459646d1a915f8d21811b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 22 Jun 2016 02:16:24 +0200 Subject: [PATCH 2/3] Typo --- bda/templates/bda-unpaid.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bda/templates/bda-unpaid.html b/bda/templates/bda-unpaid.html index df30cfd3..a424dce2 100644 --- a/bda/templates/bda-unpaid.html +++ b/bda/templates/bda-unpaid.html @@ -4,5 +4,5 @@

Impayés

-

Total : {{ unpaid|length }}

+

Total : {{ unpaid|length }}

{% endblock %} From 24e88a95a3ffd8cb765277daea90a5400febcbb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 22 Jun 2016 02:29:20 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Filtre=20les=20participants=20dans=20la=20r?= =?UTF-8?q?equ=C3=AAte=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Et non plus en python --- bda/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bda/views.py b/bda/views.py index 9b0323ce..85e62e8d 100644 --- a/bda/views.py +++ b/bda/views.py @@ -5,6 +5,7 @@ from __future__ import division from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required from django.db import models +from django.db.models import Count from django.core import serializers from django.forms.models import inlineformset_factory import hashlib @@ -329,9 +330,10 @@ class SpectacleListView(ListView): @buro_required def unpaid(request, tirage_id): tirage = get_object_or_404(Tirage, id=tirage_id) - unpaid = tirage.participant_set.filter(paid=False).all() - really_unpaid = [part for part in unpaid if part.attribution_set.all()] - return render(request, "bda-unpaid.html", {"unpaid": really_unpaid}) + 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}) @buro_required def liste_spectacles_ics(request, tirage_id):