On déplace BackgroundUpdateView dans shared
This commit is contained in:
parent
d8dba17731
commit
1353c4e702
2 changed files with 21 additions and 19 deletions
|
@ -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
19
shared/views.py
Normal 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)
|
Loading…
Reference in a new issue