Commit 12795fdf authored by Simon Daron's avatar Simon Daron

Add podcast to Listen & correct episode urls

parent d2a7f65c
......@@ -19,6 +19,7 @@ def audio(sound=None):
@register.inclusion_tag('episodes/resume.html', takes_context=True)
def episode_resume(context, date=None):
return {
'emission': context.get('emission'),
'episode': context.get('episode'),
'date': date,
}
......@@ -26,6 +27,7 @@ def episode_resume(context, date=None):
@register.inclusion_tag('episodes/inline.html', takes_context=True)
def episode_inline(context, date=None):
return {
'emission': context.get('emission'),
'episode': context.get('episode'),
'date': date,
}
......
......@@ -292,6 +292,26 @@ class Listen(TemplateView):
def get_context_data(self, **kwargs):
context = super(Listen, self).get_context_data(**kwargs)
context['sounds'] = SoundFile.objects.all()[:15]
listenable = []
x=0
for episode in Episode.objects.all().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').reverse():
if x >= 24:
break
elif episode.has_sound is None:
continue
else:
x+=1
listenable .append(episode)
context['episodes'] = listenable
return context
listen = Listen.as_view()
......
......@@ -47,7 +47,7 @@
</ul>
{% endfor %}
</div>
{% endif %}
{% endif %}
</div>
</div>
{% endblock %}
......
......@@ -23,7 +23,7 @@
</div>
{% endif %}
<div class="content">
<a class="block" href="{{ episode.slug }}">
<a class="block" href="{% url 'episode-view' emission_slug=episode.emission.slug slug=episode.slug %}">
<h5 class="title ellipsis">{{ episode.title }}</h5>
{% if episode.description %}
<div class="description ellipsis">
......
......@@ -30,7 +30,7 @@
</div>
{% endif %}
<div class="content">
<h5 class="title"><a href="{{ episode.slug }}">{{ episode.title }}</a></h5>
<h5 class="title"><a href="{% url 'episode-view' emission_slug=episode.emission.slug slug=episode.slug %}">{{ episode.title }}</a></h5>
{% if episode.description %}
<article class="text">
......
{% extends "base.html" %}
{% load paniktags %}
{% block bodyID %}Player{% endblock %}
{% block main %}
<div class="wrapper padded">
<ul class="small custom list columns">
{% for sound in sounds %}
<li class="item ellipsis">
{% include "includes/audio.html" with src=sound.file %}
{{ sound.episode }}
<ul class="custom">
{% for episode in episodes %}
<li class="item">
{% episode_inline %}
</li>
{% endfor %}
</ul>
......
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