Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikweb
Commits
d8fa908d
Commit
d8fa908d
authored
Jul 17, 2021
by
fred
Browse files
redirect to emission page when there's a single emission
parent
172b8e8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
espeweb/views.py
View file @
d8fa908d
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
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment