Commit 30b6aafa authored by Simon Daron's avatar Simon Daron
Browse files

Ad brother episodes for episode view to allow nav

parent afd4df05
......@@ -122,6 +122,30 @@ class EpisodeDetailView(DetailView):
context['add_soundfile_form'] = SoundFileForm(initial={'episode': self.object})
context['add_diffusion_form'] = DiffusionForm(initial={'episode': self.object})
context['emission'] = Emission.objects.get(slug=self.kwargs.get('emission_slug'))
# get all episodes, with an additional attribute to get the date of
# their first diffusion
context['episodes'] = \
'first_diffusion': 'emissions_diffusion.datetime',
select_params=(False, True),
where=['''datetime = (SELECT MIN(datetime)
FROM emissions_diffusion
WHERE episode_id ='''],
# get all related soundfiles in a single query
soundfiles = {}
for soundfile in SoundFile.objects.filter(podcastable=True,
fragment=False, episode__emission=self.object):
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(
return context
Supports Markdown
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