Avoid moving role order in election by reloading page

This commit is contained in:
Antoine Bartuccio 2017-12-05 14:22:59 +01:00
parent bc7cfc2dba
commit 4217b92941
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 3 additions and 1 deletions

View File

@ -280,7 +280,7 @@ th {
<tbody data-max-choice="{{role.max_choice}}" class="role{{ ' role_error' if role.title in election_form.errors else '' }}{{ ' role__multiple-choices' if role.max_choice > 1 else ''}}">
<tr class="role__title">
<td colspan="{{ election_lists.count() + 1 }}">
<span>{{ role.title }}</span>
<span><b>{{ role.title }}</b></span>
{% if user.can_edit(role) and election.is_vote_editable -%}
<a href="{{url('election:update_role', role_id=role.id)}}">{% trans %}Edit{% endtrans %}</a>
<a href="{{url('election:delete_role', role_id=role.id)}}">{% trans %}Delete{% endtrans %}</a>

View File

@ -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):