From 0c9f73a0fac2b83e3d7fca9ab74eb6e59d668a8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 22 Jul 2020 17:00:51 +0200 Subject: [PATCH] add page with list of zones, to access settings --- nonstop/templates/nonstop/quick_links.html | 1 + nonstop/templates/nonstop/zone_settings.html | 2 +- nonstop/templates/nonstop/zones.html | 26 ++++++++++++++++++++ nonstop/urls.py | 3 ++- nonstop/views.py | 10 +++++++- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 nonstop/templates/nonstop/zones.html diff --git a/nonstop/templates/nonstop/quick_links.html b/nonstop/templates/nonstop/quick_links.html index 60c1036..51f5cd0 100644 --- a/nonstop/templates/nonstop/quick_links.html +++ b/nonstop/templates/nonstop/quick_links.html @@ -25,6 +25,7 @@
  • fichiers au hasards
  • Nettoyage de vieux morceaux
  • +
  • Paramétrages des zones
  • Statistiques
  • {% endif %} diff --git a/nonstop/templates/nonstop/zone_settings.html b/nonstop/templates/nonstop/zone_settings.html index 061a0f3..f733778 100644 --- a/nonstop/templates/nonstop/zone_settings.html +++ b/nonstop/templates/nonstop/zone_settings.html @@ -17,7 +17,7 @@
    - {% trans "Cancel" %} + {% trans "Cancel" %}
    diff --git a/nonstop/templates/nonstop/zones.html b/nonstop/templates/nonstop/zones.html new file mode 100644 index 0000000..762d79d --- /dev/null +++ b/nonstop/templates/nonstop/zones.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block appbar %} +

    Nonstop - Zones

    +{% endblock %} + +{% block more-user-links %} +{{ block.super }} +Gestion nonstop +{% endblock %} + +{% block content %} + +
    + +
    + +{% endblock %} diff --git a/nonstop/urls.py b/nonstop/urls.py index b34c3b9..c9d320e 100644 --- a/nonstop/urls.py +++ b/nonstop/urls.py @@ -7,7 +7,7 @@ from .views import (SomaDayArchiveView, SomaDayArchiveCsvView, RedirectTodayView UploadTracksView, RecentTracksMetadataView, RandomTracksMetadataView, QuickLinksView, SearchView, CleanupView, ArtistTracksMetadataView, SearchCsvView, AddSomaDiffusionView, DelSomaDiffusionView, - DiffusionPropertiesView, AjaxProgram, ZoneSettings, + DiffusionPropertiesView, AjaxProgram, ZonesView, ZoneSettings, jingle_audio_view, MuninTracks) @@ -20,6 +20,7 @@ urlpatterns = [ url(r'^artists/$', ArtistListView.as_view(), name='artist-list'), url(r'^artists/(?P\d+)/$', ArtistDetailView.as_view(), name='artist-view'), + url(r'^zones/$$', ZonesView.as_view(), name='nonstop-zones'), url(r'^zones/(?P[\w-]+)/settings/$', ZoneSettings.as_view(), name='zone-settings'), # Example: /2012/nov/10/ diff --git a/nonstop/views.py b/nonstop/views.py index c8218cf..6a58773 100644 --- a/nonstop/views.py +++ b/nonstop/views.py @@ -96,6 +96,14 @@ class ArtistListView(ListView): model = Artist +class ZonesView(ListView): + model = Nonstop + template_name = 'nonstop/zones.html' + + def get_queryset(self): + return sorted(super().get_queryset(), key=lambda x: datetime.time(23, 59) if (x.start == x.end) else x.start) + + class ZoneStats(object): def __init__(self, zone, from_date=None, until_date=None, **kwargs): self.zone = zone @@ -549,7 +557,7 @@ class AjaxProgram(TemplateView): class ZoneSettings(FormView): form_class = ZoneSettingsForm template_name = 'nonstop/zone_settings.html' - success_url = reverse_lazy('nonstop-quick-links') + success_url = reverse_lazy('nonstop-zones') def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) -- 2.39.2