On modifie la façon dont on choisit le lien de retour

This commit is contained in:
Tom Hubrecht 2021-03-31 20:27:23 +02:00
parent 71a1e6c5fc
commit 4d221047c3
2 changed files with 10 additions and 10 deletions

View file

@ -18,7 +18,7 @@
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
<a class="button is-primary" href="{% url return_pattern election.pk %}"> <a class="button is-primary" href="{% if can_delete %}{% url 'election.admin' election.pk %}{% else %}{% url 'election.view' election.pk %}{% endif %}">
<span class="icon is-small"> <span class="icon is-small">
<i class="fas fa-undo-alt"></i> <i class="fas fa-undo-alt"></i>
</span> </span>

View file

@ -427,17 +427,17 @@ class ElectionVotersView(NotArchivedMixin, DetailView):
template_name = "elections/election_voters.html" template_name = "elections/election_voters.html"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
user = self.request.user
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
election = context["election"] election = context["election"]
context["can_delete"] = (
not election.restricted if user.is_authenticated:
and election.created_by == self.request.user context["can_delete"] = (
and election.end_date < timezone.now() not election.restricted
and not election.tallied and election.created_by == user
) and election.end_date < timezone.now()
context["return_pattern"] = ( and not election.tallied
"election." + "admin" if context["can_delete"] else "view" )
)
return context return context