Browse Source

feat(scrutin): détaille les émargements

pull/8/head
François Poulain 3 years ago committed by François Poulain
parent
commit
b15df57c9a
  1. 2
      TODO
  2. 23
      gvot/base/edit_handlers.py
  3. 4
      gvot/base/models.py
  4. 32
      gvot/templates/modeladmin/attendees.html
  5. 25
      gvot/templates/modeladmin/results.html

2
TODO

@ -32,7 +32,7 @@ @@ -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

23
gvot/base/edit_handlers.py

@ -28,3 +28,26 @@ class ResultsPanel(EditHandler): @@ -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(),
},
)
)

4
gvot/base/models.py

@ -38,7 +38,7 @@ from wagtail.core.models import Page @@ -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): @@ -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): @@ -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"),
]
)

32
gvot/templates/modeladmin/attendees.html

@ -0,0 +1,32 @@ @@ -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>

25
gvot/templates/modeladmin/results.html

@ -9,15 +9,16 @@ @@ -9,15 +9,16 @@
<h3>
Résultats
</h3>
<ul>
{% for field, field_results in results.items %}
<li style="padding-left: 2em;">
{{ field }}<br>
<ul>
{% for choice, count in field_results %}
<li style="padding-left: 2em;">{{ choice }} : {{ count }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
<ul>
{% for field, field_results in results.items %}
<li style="padding-left: 2em;">
{{ field }}<br>
<ul>
{% for choice, count in field_results %}
<li style="padding-left: 2em;">{{ choice }} : {{ count }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>

Loading…
Cancel
Save
Map all the world