feat(scrutin): détaille les émargements

pull/8/head
François Poulain 2020-06-18 20:43:59 +02:00 commité par François Poulain
Parent 1ca3ecb316
révision b15df57c9a
5 fichiers modifiés avec 72 ajouts et 14 suppressions

2
TODO
Voir le fichier

@ -32,7 +32,7 @@
[x] inclure un entête list-unsubscribe
[x] présenter les résultats
[ ] présenter les émargements
[x] présenter les émargements
Notes :
- rejeter les pouvoirs invalides ne permet pas de lire tous les inscrits/mandats

Voir le fichier

@ -28,3 +28,26 @@ class ResultsPanel(EditHandler):
},
)
)
class AttendeesPanel(EditHandler):
template = "modeladmin/attendees.html"
def render(self):
from .models import Pouvoir
emargement = Pouvoir.objects.filter(
vote__page=self.instance
).distinct()
participation = emargement.count()
expression = self.instance.vote_set.all().count()
return mark_safe(
render_to_string(
self.template,
{
'expression': expression,
'participation': participation,
'emargement': emargement.values(),
},
)
)

Voir le fichier

@ -38,7 +38,7 @@ from wagtail.core.models import Page
from wagtail.search import index
from . import blocks, emails, validators
from .edit_handlers import ResultsPanel
from .edit_handlers import AttendeesPanel, ResultsPanel
from .tapeforms import BigLabelTapeformMixin
@ -276,6 +276,7 @@ class Scrutin(RoutablePageMixin, AbstractEmailForm):
promote_panels = Page.promote_panels
settings_panels = Page.settings_panels + [FieldPanel('confirm_tpl')]
results_panels = [ResultsPanel()]
attendees_panels = [AttendeesPanel()]
edit_handler = TabbedInterface(
[
@ -285,6 +286,7 @@ class Scrutin(RoutablePageMixin, AbstractEmailForm):
ObjectList(
settings_panels, heading="Paramètres", classname='settings'
),
ObjectList(attendees_panels, heading="Émargements"),
ObjectList(results_panels, heading="Résultats"),
]
)

Voir le fichier

@ -0,0 +1,32 @@
{% load static %}
<div class="overflow">
<h3>
Participation : {{ participation }} pouvoir{{ participation | pluralize }}
</h3>
<h3>
Expression : {{ expression }} pouvoir{{ expression | pluralize }} pondéré{{ expression | pluralize }}
</h3>
<h3>
Émargement
</h3>
<table class="listing">
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Collectif</th>
<th>Pondération</th>
</tr>
</thead>
<tbody>
{% for pouvoir in emargement %}
<tr>
<td>{{ pouvoir.prenom }}</td>
<td>{{ pouvoir.nom }}</td>
<td>{{ pouvoir.collectif}}</td>
<td>{{ pouvoir.ponderation }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

Voir le fichier

@ -21,3 +21,4 @@
</li>
{% endfor %}
</ul>
</div>