On déplace BackgroundUpdateView dans shared

This commit is contained in:
Tom Hubrecht 2021-05-30 14:20:24 +02:00
parent d8dba17731
commit 1353c4e702
2 changed files with 21 additions and 19 deletions

View file

@ -17,12 +17,13 @@ from django.views.generic import (
DetailView,
FormView,
ListView,
RedirectView,
UpdateView,
View,
)
from django.views.generic.detail import SingleObjectMixin
from shared.views import BackgroundUpdateView
from .forms import (
DeleteVoteForm,
ElectionForm,
@ -47,24 +48,6 @@ User = get_user_model()
# TODO: access control *everywhere*
# #############################################################################
# Utils Views
# #############################################################################
class BackgroundUpdateView(RedirectView):
success_message = ""
def get_success_message(self):
return self.success_message
def get(self, request, *args, **kwargs):
success_message = self.get_success_message()
if success_message:
messages.success(self.request, success_message)
return super().get(request, *args, **kwargs)
# #############################################################################
# Administration Views
# #############################################################################

19
shared/views.py Normal file
View file

@ -0,0 +1,19 @@
from django.contrib import messages
from django.views.generic import RedirectView
# #############################################################################
# Utils Views
# #############################################################################
class BackgroundUpdateView(RedirectView):
success_message = ""
def get_success_message(self):
return self.success_message
def get(self, request, *args, **kwargs):
success_message = self.get_success_message()
if success_message:
messages.success(self.request, success_message)
return super().get(request, *args, **kwargs)