]> git.0d.be Git - django-panik-nonstop.git/commitdiff
misc: add page to edit metadata of random unclassified tracks
authorFrédéric Péters <fpeters@0d.be>
Thu, 16 Jul 2020 12:12:40 +0000 (14:12 +0200)
committerFrédéric Péters <fpeters@0d.be>
Thu, 16 Jul 2020 12:12:40 +0000 (14:12 +0200)
nonstop/templates/nonstop/quick_links.html
nonstop/templates/nonstop/recent_tracks.html [deleted file]
nonstop/templates/nonstop/tracks_metadata.html [new file with mode: 0644]
nonstop/urls.py
nonstop/views.py

index 775fde7b34f0b038eb8f768d3cb2f243b7e38e9a..ce8d865a7bd32ad4996f613601b3163f852e4ff0 100644 (file)
  <li><a href="{% url 'nonstop-search' %}">Recherche</a> dans les pistes et artistes</li>
 {% if perms.nonstop.add_track %}
  <li><a href="{% url 'nonstop-upload-tracks' %}">Ajout de nouveaux morceaux</a></li>
- <li><a href="{% url 'nonstop-recent-tracks' %}">Édition rapide de métadonnées de nouveaux morceaux</a> (langue, Instru, SABAM, CFWB)</li>
+ <li>Édition rapide des métadonnées (langue, Instru, SABAM, CFWB)
+   <ul>
+     <li><a href="{% url 'nonstop-recent-tracks' %}">nouveaux fichiers</a></li>
+     <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-stats' %}">Statistiques</a></li>
 {% endif %}
diff --git a/nonstop/templates/nonstop/recent_tracks.html b/nonstop/templates/nonstop/recent_tracks.html
deleted file mode 100644 (file)
index 34ecfbf..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-{% extends "base.html" %}
-{% load i18n %}
-
-{% block appbar %}
-<h2>Nonstop - {% trans "Recent Tracks" %}</h2>
-{% endblock %}
-
-{% block more-user-links %}
-{{ block.super }}
-<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
-{% endblock %}
-
-{% block content %}
-<form method="post">
-{% csrf_token %}
-<table id="edit-recent">
-<thead>
- <tr><th>{% trans "Title" %}</th><th>{% trans "Artist" %}</th>
-     <th class="en">EN</th><th class="fr">FR</th><th class="nl">NL</th><th class="other">Other</th><th class="na">n.a.</th>
-     <th class="instru">Instru</th><th class="sabam">Sabam</th><th class="cfwb">CFWB</th></tr>
-</thead>
-<tbody>
-{% for track in object_list %}
-<tr>
- <td><input type="hidden" name="track" value="{{track.id}}">{{track.title}}</td><td>{{track.artist.name}}</td>
- <td class="en"><input type="radio" name="lang-{{track.id}}" value="en" {% if track.language == "en" %}checked{% endif %}></td>
- <td class="fr"><input type="radio" name="lang-{{track.id}}" value="fr" {% if track.language == "fr" %}checked{% endif %}></td>
- <td class="nl"><input type="radio" name="lang-{{track.id}}" value="nl" {% if track.language == "nl" %}checked{% endif %}></td>
- <td class="other"><input type="radio" name="lang-{{track.id}}" value="other" {% if track.language == "other" %}checked{% endif %}></td>
- <td class="na"><input type="radio" name="lang-{{track.id}}" value="na" {% if track.language == "na" %}checked{% endif %}></td>
- <td class="instru"><input type="checkbox" name="instru-{{track.id}}" {% if track.instru %}checked{% endif %}></td>
- <td class="sabam"><input type="checkbox" name="sabam-{{track.id}}" {% if track.sabam %}checked{% endif %}></td>
- <td class="cfwb"><input type="checkbox" name="cfwb-{{track.id}}" {% if track.cfwb %}checked{% endif %}></td>
-</tr>
-{% endfor %}
-</tbody>
-</table>
-
-  <div class="buttons">
-    <button class="submit-button">{% trans "Save" %}</button>
-  </div>
-</form>
-
-<style>
-table#edit-recent th,
-table#edit-recent td {
-  padding: 0 1ex;
-}
-</style>
-
-<script>
-$('table#edit-recent th').on('click', function() {
-  var propvalue = true;
-  if ($(this)[0].className == 'sabam') propvalue = false;
-  $('tbody').find('.' + $(this)[0].className + ' input').prop('checked', propvalue);
-});
-</script>
-
-{% endblock %}
diff --git a/nonstop/templates/nonstop/tracks_metadata.html b/nonstop/templates/nonstop/tracks_metadata.html
new file mode 100644 (file)
index 0000000..27817cd
--- /dev/null
@@ -0,0 +1,64 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+<h2>Nonstop - {{ view.page_title }}</h2>
+{% endblock %}
+
+{% block more-user-links %}
+{{ block.super }}
+<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
+{% endblock %}
+
+{% block content %}
+<form method="post">
+{% csrf_token %}
+<table id="edit-recent">
+<thead>
+ <tr><th>{% trans "Title" %}</th><th>{% trans "Artist" %}</th>
+     <th class="en">EN</th><th class="fr">FR</th><th class="nl">NL</th><th class="other">Other</th><th class="na">n.a.</th>
+     <th class="instru">Instru</th><th class="sabam">Sabam</th><th class="cfwb">CFWB</th></tr>
+</thead>
+<tbody>
+{% for track in object_list %}
+<tr>
+ <td><input type="hidden" name="track" value="{{track.id}}">{{track.title}}</td><td>{{track.artist.name|default:"-"}}</td>
+ <td class="en"><input type="radio" name="lang-{{track.id}}" value="en" {% if track.language == "en" %}checked{% endif %}></td>
+ <td class="fr"><input type="radio" name="lang-{{track.id}}" value="fr" {% if track.language == "fr" %}checked{% endif %}></td>
+ <td class="nl"><input type="radio" name="lang-{{track.id}}" value="nl" {% if track.language == "nl" %}checked{% endif %}></td>
+ <td class="other"><input type="radio" name="lang-{{track.id}}" value="other" {% if track.language == "other" %}checked{% endif %}></td>
+ <td class="na"><input type="radio" name="lang-{{track.id}}" value="na" {% if track.language == "na" %}checked{% endif %}></td>
+ <td class="instru"><input type="checkbox" name="instru-{{track.id}}" {% if track.instru %}checked{% endif %}></td>
+ <td class="sabam"><input type="checkbox" name="sabam-{{track.id}}" {% if track.sabam %}checked{% endif %}></td>
+ <td class="cfwb"><input type="checkbox" name="cfwb-{{track.id}}" {% if track.cfwb %}checked{% endif %}></td>
+</tr>
+{% endfor %}
+</tbody>
+</table>
+
+  <div class="buttons">
+    <button class="submit-button">{% trans "Save" %}</button>
+  </div>
+</form>
+
+<style>
+table#edit-recent th,
+table#edit-recent td {
+  padding: 0 1ex;
+}
+</style>
+
+<script>
+$('table#edit-recent th').on('click', function() {
+  var propvalue = true;
+  if ($(this)[0].className == 'sabam') propvalue = false;
+  $('tbody').find('.' + $(this)[0].className + ' input').prop('checked', propvalue);
+});
+$('input[type=checkbox][name^=instru]').on('change', function() {
+  if ($(this).is(':checked')) {
+    $(this).parents('tr').find('input[name^=lang][value=na]').trigger('click');
+  }
+});
+</script>
+
+{% endblock %}
index 9ce0904d74759a5221d76200cd4e80add62e0915..cb54c506a4350d24a73a6fc1535e43a82e496a91 100644 (file)
@@ -4,7 +4,8 @@ from django.views.generic import RedirectView
 
 from .views import (SomaDayArchiveView, SomaDayArchiveCsvView, RedirectTodayView,
         TrackDetailView, ArtistDetailView, ArtistListView, StatisticsView,
-        UploadTracksView, RecentTracksView, QuickLinksView, SearchView, CleanupView,
+        UploadTracksView, RecentTracksMetadataView, RandomTracksMetadataView,
+        QuickLinksView, SearchView, CleanupView,
         SearchCsvView, AddSomaDiffusionView, DelSomaDiffusionView,
         DiffusionPropertiesView, AjaxProgram, ZoneSettings,
         jingle_audio_view)
@@ -29,7 +30,8 @@ urlpatterns = [
         name="archive_day_csv"),
 
     url(r'^upload/$', UploadTracksView.as_view(), name='nonstop-upload-tracks'),
-    url(r'^recent/$', RecentTracksView.as_view(), name='nonstop-recent-tracks'),
+    url(r'^metadata/recent/$', RecentTracksMetadataView.as_view(), name='nonstop-recent-tracks'),
+    url(r'^metadata/random/$', RandomTracksMetadataView.as_view(), name='nonstop-random-tracks'),
     url(r'^search/$', SearchView.as_view(), name='nonstop-search'),
     url(r'^search/csv$', SearchCsvView.as_view(), name='nonstop-search-csv'),
     url(r'^quick-links/$', RedirectView.as_view(url=reverse_lazy('nonstop-quick-links'))),
index 48b7ad90794aad1e5400161220cbf557a9bb5454..ce90c0948a384679d083cda9835e7e3bedf21dd6 100644 (file)
@@ -267,11 +267,13 @@ class UploadTracksView(FormView):
         return self.form_valid(form)
 
 
-class RecentTracksView(ListView):
-    template_name = 'nonstop/recent_tracks.html'
+class TracksMetadataView(ListView):
+    template_name = 'nonstop/tracks_metadata.html'
 
-    def get_queryset(self):
-        return Track.objects.exclude(creation_timestamp__isnull=True).order_by('-creation_timestamp')[:50]
+    def get_context_data(self, **kwargs):
+        context = super().get_context_data(**kwargs)
+        context['view'] = self
+        return context
 
     def post(self, request, *args, **kwargs):
         assert self.request.user.has_perm('nonstop.add_track')
@@ -285,6 +287,20 @@ class RecentTracksView(ListView):
         return HttpResponseRedirect('.')
 
 
+class RandomTracksMetadataView(TracksMetadataView):
+    page_title = _('Metadata of random tracks')
+
+    def get_queryset(self):
+        return Track.objects.filter(Q(language='') | Q(language__isnull=True)).order_by('?')[:50]
+
+
+class RecentTracksMetadataView(TracksMetadataView):
+    page_title = _('Metadata of recent tracks')
+
+    def get_queryset(self):
+        return Track.objects.exclude(creation_timestamp__isnull=True).order_by('-creation_timestamp')[:50]
+
+
 class QuickLinksView(TemplateView):
     template_name = 'nonstop/quick_links.html'