Commit d8fa908d authored by fred's avatar fred
Browse files

redirect to emission page when there's a single emission

parent 172b8e8a
import datetime
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views.generic.base import TemplateView
from emissions.models import Diffusion, Emission, Episode, NewsItem
......@@ -17,6 +19,12 @@ class Home(panikweb.views.Home):
context['extra_pages'] = Page.objects.filter(exclude_from_navigation=False)
return context
def get(request, *args, **kwargs):
emissions = Emission.objects.filter(archived=False)
if len(emissions) == 1:
return HttpResponseRedirect(reverse('emission-view', kwargs={'slug': emissions[0].slug}))
return super().get(request, *args, **kwargs)
home = Home.as_view()
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