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-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">
<i class="fas fa-undo-alt"></i>
</span>

View file

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