feat(scrutin): détaille les émargements
Parent
1ca3ecb316
révision
b15df57c9a
2
TODO
2
TODO
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
},
|
||||
)
|
||||
)
|
||||
|
|
|
@ -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"),
|
||||
]
|
||||
)
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket