Compare commits

..

2 Commits

Author SHA1 Message Date
bkfox
e94aeb2440 rename some titles/menu; remove popup on '*/orders?' 2022-05-03 11:24:06 +02:00
bkfox
1ee5e57547 avoid log repetition when it is the same 2022-05-02 10:04:14 +02:00
3 changed files with 15 additions and 3 deletions

View File

@ -127,7 +127,6 @@ class Program(Page):
def save(self, *kargs, **kwargs):
from .sound import Sound
super().save(*kargs, **kwargs)
# TODO: move in signals

View File

@ -1,6 +1,8 @@
from collections import deque
import datetime
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from django.views.generic import ListView
from django.utils import timezone as tz
@ -91,6 +93,10 @@ class LogListAPIView(LogListMixin, BaseAPIView, ListAPIView):
serializer_class = LogInfoSerializer
queryset = Log.objects.all()
@method_decorator(cache_page(5))
def list(self, *args, **kwargs):
return super().list(*args, **kwargs)
def get_date(self):
date = super().get_date()
if date is None:

View File

@ -122,10 +122,17 @@ class Monitor:
self.handle_diffusions()
self.sync()
def log(self, date=None, **kwargs):
__last_log_kwargs = None
def log(self, **kwargs):
""" Create a log using **kwargs, and print info """
if self.__last_log_kwargs == kwargs:
return
self.__last_log_kwargs = kwargs
kwargs.setdefault('station', self.station)
log = Log(date=date or tz.now(), **kwargs)
kwargs.setdefault('date', tz.now())
log = Log(**kwargs)
log.save()
log.print()
return log