]> git.0d.be Git - panikweb.git/commitdiff
publish nonstop playlists
authorFrédéric Péters <fpeters@0d.be>
Sun, 29 Nov 2015 12:07:29 +0000 (13:07 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sun, 29 Nov 2015 12:07:29 +0000 (13:07 +0100)
panikweb/urls.py
panikweb/views.py
panikweb_templates/static/css/specifics.css
panikweb_templates/templates/emissions/emission_detail.html
panikweb_templates/templates/nonstop_playlist.html [new file with mode: 0644]

index ef1e3eac1a00748ca25201ee2c6a27a5d8058b4e..123b0ca6b6372ca4fc97ddf34f4fa79315f1fb31 100644 (file)
@@ -20,6 +20,8 @@ urlpatterns = patterns('',
         'panikweb.views.soundfile_embed', name='soundfile-embed-view'),
     url(r'^emissions/(?P<emission_slug>[\w,-]+)/(?P<episode_slug>[\w,-]+)/dlg-embed/(?P<pk>\d+)/$',
         'panikweb.views.soundfile_dlg_embed', name='soundfile-dialog-embed-view'),
+    url(r'^emissions/(?P<slug>[\w,-]+)/playlist/(?P<year>[0-9]{4})-(?P<month>[-\w]+)-(?P<day>[0-9]+)/$',
+        'panikweb.views.nonstop_playlist', name='nonstop-playlist'),
     url(r'^emissions/(?P<slug>[\w,-]+)/$', 'panikweb.views.emission', name='emission-view'),
     url(r'^ckeditor/', include('ckeditor.urls')),
     url(r'^emissions/archives$', 'panikweb.views.emissionsArchives', name='emissionsArchives'),
index 8167a507c82a90a4712a094fab7f6c7d7ce66808..3872ac4a83165d35d1d02a9ae6daf4ed026c7645 100644 (file)
@@ -31,6 +31,7 @@ from emissions.utils import whatsonair, period_program
 
 from newsletter.forms import SubscribeForm
 from nonstop.utils import get_current_nonstop_track
+from nonstop.models import SomaLogLine
 
 from panikombo.models import ItemTopik
 
@@ -102,6 +103,18 @@ class EmissionDetailView(DetailView, EmissionMixin):
         context['schedules'] = Schedule.objects.select_related().filter(
                 emission=self.object).order_by('rerun', 'datetime')
         context['news'] = NewsItem.objects.all().filter(emission=self.object.id).order_by('-date')[:3]
+        try:
+            nonstop_object = Nonstop.objects.get(slug=self.object.slug)
+        except Nonstop.DoesNotExist:
+            pass
+        else:
+            today = date.today()
+            dates = [today - timedelta(days=x) for x in range(7)]
+            if datetime.now().time() < nonstop_object.start and not (
+                    nonstop_object.end < nonstop_object.start):
+                dates = dates[1:]
+            context['nonstop'] = nonstop_object
+            context['nonstop_dates'] = dates
         context.update(self.get_emission_context(self.object))
         return context
 emission = EmissionDetailView.as_view()
@@ -125,6 +138,32 @@ class EpisodeDetailView(DetailView, EmissionMixin):
 episode = EpisodeDetailView.as_view()
 
 
+class NonstopPlaylistView(TemplateView):
+    template_name = 'nonstop_playlist.html'
+
+    def get_context_data(self, **kwargs):
+        context = super(NonstopPlaylistView, self).get_context_data(**kwargs)
+        context['emission'] = Emission.objects.get(slug=kwargs.get('slug'))
+        context['date'] = date(int(kwargs.get('year')),
+                int(kwargs.get('month')), int(kwargs.get('day')))
+
+        nonstop_object = Nonstop.objects.get(slug=kwargs.get('slug'))
+        start = datetime(
+                int(kwargs.get('year')), int(kwargs.get('month')), int(kwargs.get('day')),
+                nonstop_object.start.hour, nonstop_object.start.minute)
+        end = datetime(
+                int(kwargs.get('year')), int(kwargs.get('month')), int(kwargs.get('day')),
+                nonstop_object.end.hour, nonstop_object.end.minute)
+        if end < start:
+            end = end + timedelta(days=1)
+        context['tracks'] = SomaLogLine.objects.filter(
+                play_timestamp__gte=start,
+                play_timestamp__lte=end,
+                on_air=True).select_related()
+        return context
+
+nonstop_playlist = NonstopPlaylistView.as_view()
+
 class EmissionEpisodesDetailView(DetailView, EmissionMixin):
     model = Emission
     template_name = 'emissions/episodes.html'
index 8fba570023b1cdd86f77b881320a80d6aea28645..d666a0650b09b4708c8e92999a77ea016b4277e3 100644 (file)
@@ -1823,3 +1823,23 @@ body#embed ul.custom .soundfile-info {
 body#embed span.fragment-title {
        font-weight: normal;
 }
+
+table.playlist {
+       width: 90%;
+}
+
+table.playlist td {
+       padding: 0.5ex;
+       text-align: left;
+}
+
+table.playlist td.tracktime {
+       width: 6ex;
+       text-align: center;
+}
+
+p.playlist-disclaimer {
+       margin-top: 2em;
+       max-width: 60ex;
+       font-style: italic;
+}
index 386068cdabd9bab7c114e782f46a616d626c9a9f..4d284337a3c62703232b856e828227cd895a065a 100644 (file)
@@ -1,5 +1,5 @@
 {% extends "emissions.html" %}
-{% load paniktags staticfiles i18n %}
+{% load paniktags staticfiles i18n thumbnail %}
 {% block bodyID %}Emissions{% endblock %}
 {% block title %}{{ emission.title }}{% endblock %}
 
@@ -31,7 +31,7 @@
                                {% endif %}
                        </div>
 
-               {% if episodes.exists or futurEpisodes.exists or news %}
+               {% if episodes.exists or futurEpisodes.exists or news or nonstop %}
                        <div id="Emission-tabs-menu" class="rightPart episodes">
 
                                {% if news %}
                                        </div>
                                {% endif %}
 
+                       {% if nonstop %}
+                               <div class="sub emissions-newsitems">
+                                       <h5 class="sectionLabel">{% trans 'Recently' %}</h5>
+                                       {% for date in nonstop_dates %}
+                                       <div class="episode inline episode-inline">
+                                       {% if emission.image %}
+                                       {% thumbnail emission.image "60x60" crop="50% 25%" as im %}
+                                       <img src="{{im.url}}"/>
+                                       {% endthumbnail %}
+                                       {% endif %}
+                                       <div class="title">
+                                               <h5 class="title"><a href="{% url 'nonstop-playlist' slug=emission.slug year=date.year month=date.month day=date.day %}">{{date|date:'D d M Y'|lower}}</a></h5>
+                                       </div>
+                                       </div>
+                                       {% endfor %}
+                               </div>
+                       {% endif %}
+
 
                        {% if episodes.exists or futurEpisodes.exists %}
                         <h5 class="sectionLabel right"><a class="" href="{% url 'emissionEpisodes' slug=emission.slug %}">Tous ({{ episodes.count }})</a></h5>
diff --git a/panikweb_templates/templates/nonstop_playlist.html b/panikweb_templates/templates/nonstop_playlist.html
new file mode 100644 (file)
index 0000000..9b9323c
--- /dev/null
@@ -0,0 +1,40 @@
+{% extends "emissions.html" %}
+{% load paniktags staticfiles i18n thumbnail %}
+{% block bodyID %}Emissions{% endblock %}
+{% block title %}{{ emission.title }}{% endblock %}
+
+{% block toptitle %}
+<h1 class="top"><a href="{% url 'grid' %}">{% trans 'Program' %}</a></h1>
+{% endblock %}
+{% block nav %}
+       {% emission_nav %}
+{% endblock %}
+{% block main %}
+<div class="wrapper navigation cf">
+       <div id="Emission-container" class="emission">
+               <header>
+                       <h3>{% trans 'Playlist' %} - {{date|date:'l d F Y'|lower}}</h3>
+               </header>
+
+               <table class="playlist">
+               {% for track in tracks %}
+               <tr>
+                       <td class="tracktime">{{track.play_timestamp|date:'h:i'}}</td>
+                       <td class="tracktitle">{{track.filepath.track.title }}</td>
+                       <td class="trackartist">{{track.filepath.track.artist.name }}</td>
+               </tr>
+               {% endfor %}
+               </table>
+
+               <p class="playlist-disclaimer">
+                       N.B. Débordements d'émissions et autres manifestations
+                       radiophoniques spontanées peuvent amener cette liste à ne pas être
+                       totalement correcte.
+               </p>
+
+       </div>
+</div>
+{% endblock %}
+
+{% block links %}
+{% endblock %}