From 4217b929411157fadfb1c8ed0d257aa8967899d6 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 5 Dec 2017 14:22:59 +0100 Subject: [PATCH] Avoid moving role order in election by reloading page --- election/templates/election/election_detail.jinja | 2 +- election/views.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/election/templates/election/election_detail.jinja b/election/templates/election/election_detail.jinja index 26be2e3d..cf79003f 100644 --- a/election/templates/election/election_detail.jinja +++ b/election/templates/election/election_detail.jinja @@ -280,7 +280,7 @@ th { - {{ role.title }} + {{ role.title }} {% if user.can_edit(role) and election.is_vote_editable -%} {% trans %}Edit{% endtrans %} {% trans %}Delete{% endtrans %} diff --git a/election/views.py b/election/views.py index 8b77994a..8b0106d7 100644 --- a/election/views.py +++ b/election/views.py @@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _ from django.core.exceptions import PermissionDenied from django.db import transaction from django.forms import CheckboxSelectMultiple +from django.shortcuts import redirect from django import forms from core.views import CanViewMixin, CanEditMixin, CanCreateMixin @@ -192,6 +193,7 @@ class ElectionDetailView(CanViewMixin, DetailView): Role.objects.get(id=role).bottom() elif action == "top": Role.objects.get(id=role).top() + return redirect(reverse_lazy('election:detail', kwargs={'election_id': election.id})) return r def get_context_data(self, **kwargs):