From bf4cb4c9eebaa5d06aec132f32cac916c2094d34 Mon Sep 17 00:00:00 2001 From: ludo Date: Wed, 15 Jun 2016 19:34:10 +0200 Subject: [PATCH] =?UTF-8?q?Passe=20d'un=20enregistrement=20=C3=A0=20un=20d?= =?UTF-8?q?ictionnaire,=20trie=20les=20valeurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/templates/bda-participants.html | 12 ++++++------ bda/views.py | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html index c68c4390..edf2a9e2 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda-participants.html @@ -16,10 +16,10 @@ {% for participant in participants %} - {{participant.user.get_full_name}} - {{participant.user.username}} + {{participant.name}} + {{participant.username}} {{participant.nb_places}} place{{participant.nb_places|pluralize:",s"}} - {{participant.user.email}} + {{participant.email}}
{% if participant.paid %}Oui{% else %}Non{%endif%} @@ -36,14 +36,14 @@
{% spaceless %} {%endspaceless%} diff --git a/bda/views.py b/bda/views.py index 1e5a1622..7c7f735c 100644 --- a/bda/views.py +++ b/bda/views.py @@ -296,14 +296,13 @@ def spectacle(request, tirage_id, spectacle_id): participants = {} for attrib in attributions: participant = attrib.participant - participant.given = attrib.given + participant_info = {'lastname':participant.user.last_name, 'name': participant.user.get_full_name, 'username':participant.user.username, 'email':participant.user.email, 'given':attrib.given, 'paid':participant.paid, 'nb_places':1} if participant.id in participants: - participants[participant.id].nb_places = 2 + participants[participant.id]['nb_places'] = 2 else: - participant.nb_places = 1 - participants[participant.id] = participant + participants[participant.id] = participant_info - return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants.values()}) + return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": sorted(participants.values(), key=lambda part: part['lastname'])}) class SpectacleListView(ListView): model = Spectacle