]> git.0d.be Git - django-panik-nonstop.git/commitdiff
add page with list of zones, to access settings
authorFrédéric Péters <fpeters@0d.be>
Wed, 22 Jul 2020 15:00:51 +0000 (17:00 +0200)
committerFrédéric Péters <fpeters@0d.be>
Wed, 22 Jul 2020 15:01:22 +0000 (17:01 +0200)
nonstop/templates/nonstop/quick_links.html
nonstop/templates/nonstop/zone_settings.html
nonstop/templates/nonstop/zones.html [new file with mode: 0644]
nonstop/urls.py
nonstop/views.py

index 60c1036e483288174ec7fce95c05c53de3c3644d..51f5cd0614d834d73f3b6bf8e3c1ab86a1fecbb2 100644 (file)
@@ -25,6 +25,7 @@
      <li><a href="{% url 'nonstop-random-tracks' %}">fichiers au hasards</a></li>
    </ul></li>
  <li><a href="{% url 'nonstop-cleanup' %}">Nettoyage de vieux morceaux</a></li>
+ <li><a href="{% url 'nonstop-zones' %}">Paramétrages des zones</a></li>
  <li><a href="{% url 'nonstop-stats' %}">Statistiques</a></li>
 {% endif %}
 </ul>
index 061a0f30c3ea8364033ada63711440faeb4a17a2..f7337787c9a30d86381a5298627baf67325c3c2b 100644 (file)
@@ -17,7 +17,7 @@
 
   <div class="buttons">
     <button class="submit-button">{% trans "Save" %}</button>
-    <a class="cancel" href="{% url 'nonstop-quick-links' %}">{% trans "Cancel" %}</a>
+    <a class="cancel" href="{% url 'nonstop-zones' %}">{% trans "Cancel" %}</a>
   </div>
 
 </form>
diff --git a/nonstop/templates/nonstop/zones.html b/nonstop/templates/nonstop/zones.html
new file mode 100644 (file)
index 0000000..762d79d
--- /dev/null
@@ -0,0 +1,26 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+<h2>Nonstop - Zones</h2>
+{% endblock %}
+
+{% block more-user-links %}
+{{ block.super }}
+<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
+{% endblock %}
+
+{% block content %}
+
+<div class="section">
+<ul class="objects-list single-links">
+{% for zone in object_list %}
+<li {% if zone.start == zone.end %}class="disabled"{% endif %}
+        ><a href="{% url 'zone-settings' slug=zone.slug %}"><span class="tag">{{zone.start}} → {{zone.end}}</span>
+                {{ zone.title }}
+                {% if zone.start == zone.end %}<span class="extra-info disabled-zone">(zone désactivée)</span>{% endif %}</a></li>
+{% endfor %}
+</ul>
+</div>
+
+{% endblock %}
index b34c3b9fd21fbe4f709049e591b3d203dd8b8eb9..c9d320e9e1bbd63f6e26d43cf046a5aad9ae1187 100644 (file)
@@ -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<pk>\d+)/$', ArtistDetailView.as_view(), name='artist-view'),
 
+    url(r'^zones/$$', ZonesView.as_view(), name='nonstop-zones'),
     url(r'^zones/(?P<slug>[\w-]+)/settings/$', ZoneSettings.as_view(), name='zone-settings'),
 
     # Example: /2012/nov/10/
index c8218cf475469fb05161be4b171f2b712c2f4cb8..6a5877357bc907bb53e9d4929b4e1071d1d8160d 100644 (file)
@@ -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)