Ne montre la liste des participants qu'aux personnes autorisées
This commit is contained in:
parent
d98d7da399
commit
6b34c052ea
3 changed files with 199 additions and 146 deletions
|
@ -254,6 +254,9 @@ class User(AbstractUser):
|
|||
# Pour les élections restreintes, il faut y être associé
|
||||
return election.restricted and (self.election == election)
|
||||
|
||||
def is_admin(self, election):
|
||||
return election.created_by == self or self.is_staff
|
||||
|
||||
def get_prefix(self):
|
||||
return self.username.split("__")[0]
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% if can_vote or is_admin %}
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-narrow">
|
||||
{% if can_delete %}
|
||||
|
@ -109,7 +110,7 @@
|
|||
{% if can_delete %}
|
||||
<th class="has-text-centered">{% trans "Supprimer" %}</th>
|
||||
{% endif %}
|
||||
<tr>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
@ -169,10 +170,57 @@
|
|||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="notification is-danger is-light has-text-centered">
|
||||
<b>{% trans "Pour voir la liste des votant·e·s vous devez être connecté·e." %}</b>
|
||||
{% if election.restricted %}
|
||||
<br>
|
||||
<span class="icon">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
</span>
|
||||
<i>{% trans "La connexion doit s'effectuer via les identifiants reçus par mail." %}</i>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-half">
|
||||
<div class="tile is-ancestor">
|
||||
<div class="tile is-parent">
|
||||
{% if election.restricted %}
|
||||
<a class="tile is-child notification is-primary" href="{% url 'auth.election' election.pk %}?next={% url 'election.voters' election.pk %}">
|
||||
<div class="subtitle has-text-centered mb-2">
|
||||
<span class="icon-text">
|
||||
<span class="icon has-text-white">
|
||||
<i class="fas fa-unlock"></i>
|
||||
</span>
|
||||
<span class="ml-3">{% trans "Connexion par identifiants" %}</span>
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="tile is-child notification is-primary" href="{% url 'authens:login.cas' %}?next={% url 'election.voters' election.pk %}">
|
||||
<div class="subtitle has-text-centered mb-2">
|
||||
<span class="icon-text">
|
||||
<span class="icon has-text-white">
|
||||
<i class="fas fa-school"></i>
|
||||
</span>
|
||||
<span class="ml-3">{% trans "Connexion via CAS" %}</span>
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -445,6 +445,8 @@ class ElectionVotersView(NotArchivedMixin, DetailView):
|
|||
voters = list(election.voters.all())
|
||||
|
||||
if user.is_authenticated:
|
||||
context["can_vote"] = user.can_vote(self.request, context["election"])
|
||||
context["is_admin"] = user.is_admin(election)
|
||||
can_delete = (
|
||||
election.created_by == user
|
||||
and election.end_date < timezone.now()
|
||||
|
|
Loading…
Reference in a new issue