from emissions.models import Nonstop
for zone in Nonstop.objects.all():
+ if not zone.slug in TRANCHE_SLUG_DIR_MAPPING:
+ continue
zone_dir = TRANCHE_SLUG_DIR_MAPPING[zone.slug]
zone_path = os.path.join(LOCAL_BASE_PATH, 'Tranches', zone_dir, filename)
if zone in current_zones:
--- /dev/null
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+<h2>Nonstop - {% trans "Recent Tracks" %}</h2>
+{% 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="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="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 %}
from django.conf.urls import url
-from .views import SomaDayArchiveView, SomaDayArchiveCsvView, RedirectTodayView, TrackDetailView, ArtistDetailView, ArtistListView, StatisticsView, UploadTracksView
+from .views import SomaDayArchiveView, SomaDayArchiveCsvView, RedirectTodayView, TrackDetailView, ArtistDetailView, ArtistListView, StatisticsView, UploadTracksView, RecentTracksView
urlpatterns = [
# Example: /2012/nov/10/
name="archive_day_csv"),
url(r'^upload/$', UploadTracksView.as_view(), name='nonstop-upload-tracks'),
+ url(r'^recent/$', RecentTracksView.as_view(), name='nonstop-recent-tracks'),
]
track, created = Track.objects.get_or_create(title=track_title, artist=artist)
nonstop_file.track = track
nonstop_file.save()
+ nonstop_file.track.sync_nonstop_zones()
if request.POST.get('nonstop_zone'):
track.nonstop_zones.add(
Nonstop.objects.get(id=request.POST.get('nonstop_zone')))
messages.info(self.request, '%d new track(s)' % len(tracks))
return self.form_valid(form)
+
+
+class RecentTracksView(ListView):
+ template_name = 'nonstop/recent_tracks.html'
+
+ def get_queryset(self):
+ return Track.objects.all().order_by('-creation_timestamp')[:20]
+
+ def post(self, request, *args, **kwargs):
+ for track_id in request.POST.getlist('track'):
+ track = Track.objects.get(id=track_id)
+ track.language = request.POST.get('lang-%s' % track_id, '')
+ track.instru = 'instru-%s' % track_id in request.POST
+ track.sabam = 'sabam-%s' % track_id in request.POST
+ track.cfwb = 'cfwb-%s' % track_id in request.POST
+ track.save()
+ return HttpResponseRedirect('.')