2021-05-30 14:20:24 +02:00
|
|
|
from django.contrib import messages
|
2021-08-21 22:58:01 +02:00
|
|
|
from django.utils import timezone
|
2021-05-30 14:20:24 +02:00
|
|
|
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)
|
2021-08-21 22:58:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TimeMixin:
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
kwargs.update(current_time=timezone.now())
|
2024-07-10 13:51:24 +02:00
|
|
|
return super().get_context_data(**kwargs) # pyright: ignore
|