Commit 948f94f2 authored by Simon Daron's avatar Simon Daron

Archives for listen & news

parent 00b68203
...@@ -28,6 +28,13 @@ def audio(context, sound=None): ...@@ -28,6 +28,13 @@ def audio(context, sound=None):
'sound': sound 'sound': sound
} }
@register.inclusion_tag('listen/nav.html', takes_context=True)
def listen_nav(context, date=None, klass=None):
return {
'class': klass,
'categories': context.get('categories'),
}
@register.inclusion_tag('news/nav.html', takes_context=True) @register.inclusion_tag('news/nav.html', takes_context=True)
def news_nav(context, date=None, klass=None): def news_nav(context, date=None, klass=None):
return { return {
......
...@@ -21,7 +21,7 @@ urlpatterns = patterns('', ...@@ -21,7 +21,7 @@ urlpatterns = patterns('',
url(r'^emissions/archives$', 'panikweb.views.emissionsArchives', name='emissionsArchives'), url(r'^emissions/archives$', 'panikweb.views.emissionsArchives', name='emissionsArchives'),
url(r'^get$', 'panikweb.views.get', name='get'), url(r'^get$', 'panikweb.views.get', name='get'),
url(r'^listen$', 'panikweb.views.listen', name='listen'), url(r'^listen$', 'panikweb.views.listen', name='listen'),
url(r'^listen/archives$', 'panikweb.views.listen', name='listen-archives'), url(r'^listen/archives$', 'panikweb.views.listenArchives', name='listenArchives'),
url(r'^news/$', 'panikweb.views.news', name='news'), url(r'^news/$', 'panikweb.views.news', name='news'),
url(r'^news/archives$', 'panikweb.views.newsArchives', name='newsArchives'), url(r'^news/archives$', 'panikweb.views.newsArchives', name='newsArchives'),
url(r'^news/(?P<slug>[\w,-]+)$', 'panikweb.views.newsitemview', name='news-view'), url(r'^news/(?P<slug>[\w,-]+)$', 'panikweb.views.newsitemview', name='news-view'),
......
...@@ -437,7 +437,7 @@ class NewsArchives(TemplateView): ...@@ -437,7 +437,7 @@ class NewsArchives(TemplateView):
context = super(NewsArchives, self).get_context_data(**kwargs) context = super(NewsArchives, self).get_context_data(**kwargs)
context['sectionName'] = "News" context['sectionName'] = "News"
context['focus'] = list(NewsItem.objects.all().exclude(image__isnull=True).exclude(image__exact='').order_by('-datetime')[0:6]) context['focus'] = list(NewsItem.objects.all().exclude(image__isnull=True).exclude(image__exact='').order_by('-datetime')[0:6])
context['news'] = list(NewsItem.objects.all().order_by('-datetime')[0:60]) context['news'] = list(NewsItem.objects.all().order_by('-datetime')[0:600])
context['categories'] = NewsCategory.objects.all() context['categories'] = NewsCategory.objects.all()
return context return context
...@@ -505,6 +505,37 @@ class Listen(TemplateView): ...@@ -505,6 +505,37 @@ class Listen(TemplateView):
listen = Listen.as_view() listen = Listen.as_view()
class ListenArchives(TemplateView):
template_name = 'listen/archives.html'
def get_context_data(self, **kwargs):
context = super(ListenArchives, self).get_context_data(**kwargs)
context['sectionName'] = "Listen"
context['episodes'] = Episode.objects.filter(
soundfile__podcastable=True, soundfile__fragment=False) \
.select_related().extra(select={
'first_diffusion': 'emissions_diffusion.datetime', },
select_params=(False, True),
where=['''datetime = (SELECT MIN(datetime)
FROM emissions_diffusion
WHERE episode_id = emissions_episode.id)'''],
tables=['emissions_diffusion'],).order_by('-first_diffusion') [:60]
# get all related soundfiles in a single query
soundfiles = {}
for soundfile in SoundFile.objects.select_related().filter(podcastable=True,
fragment=False, episode__in=[x.id for x in context['episodes']]):
soundfiles[soundfile.episode_id] = soundfile
# replace dynamic property by a static attribute, to avoid database
# lookups
for episode in context['episodes']:
episode.main_sound = soundfiles.get(episode.id)
context['categories'] = Category.objects.all()
return context
listenArchives = ListenArchives.as_view()
@cache_control(max_age=25) @cache_control(max_age=25)
@csrf_exempt @csrf_exempt
......
...@@ -276,6 +276,7 @@ body{ ...@@ -276,6 +276,7 @@ body{
} }
#Nav nav{padding:0.1em;} #Nav nav{padding:0.1em;}
#Nav *{ color:#ddd;border-color:#ddd;} #Nav *{ color:#ddd;border-color:#ddd;}
/*#Nav form{background:#800000;}*/
#Nav input{color:#333;} #Nav input{color:#333;}
#Nav .active,#Nav .active *{ #Nav .active,#Nav .active *{
color:white !important; color:white !important;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
title="Download file" title="Download file"
onclick="$('#Download-{{ sound.file.url|slugify }}').toggle();return false;" onclick="$('#Download-{{ sound.file.url|slugify }}').toggle();return false;"
></button> ></button>
<span class="box hidden" id="Download-{{ sound.file.url|slugify }}" > <span class="hidden" id="Download-{{ sound.file.url|slugify }}" >
{% if sound|is_format_available:'ogg' %} {% if sound|is_format_available:'ogg' %}
<a target="_blanck" class="icon-file button" href="{{ sound|format_url:'ogg' }}"> <a target="_blanck" class="icon-file button" href="{{ sound|format_url:'ogg' }}">
<span>ogg</span> <span>ogg</span>
......
{% extends "base.html" %} {% extends "base.html" %}
{% load paniktags %} {% load paniktags %}
{% block nav %} {% block nav %}
<div class="wrapper"> {% listen_nav %}
{% if categories %}
<nav id="gridNav" class="checkable">
<ul class="by{{ categories.count }}">
<li><button class="check icon-check" data-about="#Main" data-toggle=".nocat">?</button></li>
{% for category in categories %}
<li><button class="check icon-check" data-about="#Main" data-toggle=".{{ category|slugify }}">{{ category }}</button></li>
{% endfor %}
</ul>
</nav>
{% endif %}
</div>
{% endblock %} {% endblock %}
{% block main %} {% block main %}
<div class="padded"> <div class="">
<ul class="custom columns list"> <ul class="padded custom columns list">
{% for episode in episodes %} {% for episode in episodes %}
<li class="item {% if episode.emission.categories.all.count = 0 %}nocat{% endif %} {% for category in episode.emission.categories.all %} {{ category|slugify }}{% endfor %}"> <li class="item {% if episode.emission.categories.all.count = 0 %}nocat{% endif %} {% for category in episode.emission.categories.all %} {{ category|slugify }}{% endfor %}">
{% episode_resume model="inline" klass="standalone"%} {% episode_resume model="inline" klass="standalone"%}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment