diff --git a/aircox/controllers.py b/aircox/controllers.py index 335e572..0147faf 100644 --- a/aircox/controllers.py +++ b/aircox/controllers.py @@ -19,7 +19,7 @@ class Streamer: """ Related station """ - template_name = 'aircox/controllers/liquidsoap.liq' + template_name = 'aircox/config/liquidsoap.liq' """ If set, use this template in order to generated the configuration file in self.path file diff --git a/aircox/management/commands/diffusions_monitor.py b/aircox/management/commands/diffusions_monitor.py index 9bf0a3b..6565c1b 100644 --- a/aircox/management/commands/diffusions_monitor.py +++ b/aircox/management/commands/diffusions_monitor.py @@ -137,7 +137,7 @@ class Command (BaseCommand): group.add_argument( '--check', action='store_true', help='check unconfirmed later diffusions from the given ' - 'date again'\'t schedule. If no schedule is found, remove ' + 'date agains\'t schedule. If no schedule is found, remove ' 'it.' ) diff --git a/aircox/management/commands/streamer.py b/aircox/management/commands/streamer.py index ac0f84c..f390eb6 100644 --- a/aircox/management/commands/streamer.py +++ b/aircox/management/commands/streamer.py @@ -105,7 +105,8 @@ class Monitor: source = current_source.id, date = tz.now(), related = sound[0] if sound else None, - comment = None if sound else current_sound, + # keep sound path (if sound is removed, we keep that info) + comment = current_sound, ) def trace_sound_tracks(self, log): diff --git a/aircox/models.py b/aircox/models.py index 953b7c8..b9497a6 100755 --- a/aircox/models.py +++ b/aircox/models.py @@ -377,52 +377,6 @@ class Program(Nameable): return qs[0] if qs else None -class DiffusionManager(models.Manager): - def get_at(self, date = None, next = False): - """ - Return a queryset of diffusions that have the given date - in their range. - - If date is a datetime.date object, check only against the - date. - """ - date = date or tz.now() - if not issubclass(type(date), datetime.datetime): - return self.filter( - models.Q(start__contains = date) | \ - models.Q(end__contains = date) - ) - - if not next: - return self.filter(start__lte = date, end__gte = date) \ - .order_by('start') - - return self.filter( - models.Q(start__lte = date, end__gte = date) | - models.Q(start__gte = date), - ).order_by('start') - - def get_after(self, date = None): - """ - Return a queryset of diffusions that happen after the given - date. - """ - date = date_or_default(date) - return self.filter( - start__gte = date, - ).order_by('start') - - def get_before(self, date): - """ - Return a queryset of diffusions that finish before the given - date. - """ - date = date_or_default(date) - return self.filter( - end__lte = date, - ).order_by('start') - - class Stream(models.Model): """ When there are no program scheduled, it is possible to play sounds @@ -671,6 +625,52 @@ class Schedule(models.Model): verbose_name_plural = _('Schedules') +class DiffusionManager(models.Manager): + def get_at(self, date = None, next = False): + """ + Return a queryset of diffusions that have the given date + in their range. + + If date is a datetime.date object, check only against the + date. + """ + date = date or tz.now() + if not issubclass(type(date), datetime.datetime): + return self.filter( + models.Q(start__contains = date) | \ + models.Q(end__contains = date) + ) + + if not next: + return self.filter(start__lte = date, end__gte = date) \ + .order_by('start') + + return self.filter( + models.Q(start__lte = date, end__gte = date) | + models.Q(start__gte = date), + ).order_by('start') + + def get_after(self, date = None): + """ + Return a queryset of diffusions that happen after the given + date. + """ + date = date_or_default(date) + return self.filter( + start__gte = date, + ).order_by('start') + + def get_before(self, date): + """ + Return a queryset of diffusions that finish before the given + date. + """ + date = date_or_default(date) + return self.filter( + end__lte = date, + ).order_by('start') + + class Diffusion(models.Model): """ A Diffusion is an occurrence of a Program that is scheduled on the @@ -1036,7 +1036,7 @@ class Log(Related): Log sounds and diffusions that are played on the station. This only remember what has been played on the outputs, not on each - track; Source designate here which source is responsible of that. + source; Source designate here which source is responsible of that. """ class Type(IntEnum): stop = 0x00 diff --git a/aircox/templates/aircox/controllers/liquidsoap.liq b/aircox/templates/aircox/config/liquidsoap.liq similarity index 100% rename from aircox/templates/aircox/controllers/liquidsoap.liq rename to aircox/templates/aircox/config/liquidsoap.liq diff --git a/aircox/templates/aircox/controllers/stats.html b/aircox/templates/aircox/controllers/stats.html new file mode 100644 index 0000000..fae3b09 --- /dev/null +++ b/aircox/templates/aircox/controllers/stats.html @@ -0,0 +1,46 @@ +{% load i18n %} + +
{% trans "Date" %} | + {# Translators "Header for statistics view" #} +{% trans "Diffusion or sound played" %} + | + | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{ item.date|date:"H:i" }} | + {# TODO: logs #} +{{ item.program.name }} | + {% for tag,count in item.tags %} +{{ tag }}: {{ count }} | + {% endfor %} +|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{ stats.date|date:'d/m/Y' }} | +{% trans "Total and average" %} ({{ stats.tracks_count }}) | + {% for tag, count, average in stats.tags %} +{{ tag }}: {{ count }} / {{ average|floatformat }}% | + {% endfor %} +