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

Archives for listen & news

parent 00b68203
......@@ -28,6 +28,13 @@ def audio(context, sound=None):
'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)
def news_nav(context, date=None, klass=None):
return {
......
......@@ -21,7 +21,7 @@ urlpatterns = patterns('',
url(r'^emissions/archives$', 'panikweb.views.emissionsArchives', name='emissionsArchives'),
url(r'^get$', 'panikweb.views.get', name='get'),
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/archives$', 'panikweb.views.newsArchives', name='newsArchives'),
url(r'^news/(?P<slug>[\w,-]+)$', 'panikweb.views.newsitemview', name='news-view'),
......
......@@ -437,7 +437,7 @@ class NewsArchives(TemplateView):
context = super(NewsArchives, self).get_context_data(**kwargs)
context['sectionName'] = "News"
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()
return context
......@@ -505,6 +505,37 @@ class Listen(TemplateView):
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)
@csrf_exempt
......
......@@ -276,6 +276,7 @@ body{
}
#Nav nav{padding:0.1em;}
#Nav *{ color:#ddd;border-color:#ddd;}
/*#Nav form{background:#800000;}*/
#Nav input{color:#333;}
#Nav .active,#Nav .active *{
color:white !important;
......
......@@ -19,7 +19,7 @@
title="Download file"
onclick="$('#Download-{{ sound.file.url|slugify }}').toggle();return false;"
></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' %}
<a target="_blanck" class="icon-file button" href="{{ sound|format_url:'ogg' }}">
<span>ogg</span>
......
{% extends "base.html" %}
{% load paniktags %}
{% block nav %}
<div class="wrapper">
{% 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>
{% listen_nav %}
{% endblock %}
{% block main %}
<div class="padded">
<ul class="custom columns list">
<div class="">
<ul class="padded custom columns list">
{% 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 %}">
{% 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