avoid log repetition when it is the same

This commit is contained in:
bkfox 2022-05-02 10:04:14 +02:00
parent a805ce6777
commit 1ee5e57547
2 changed files with 9 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

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