Skip to content
GitLab
Menu
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
2a344dd7
Commit
2a344dd7
authored
Sep 16, 2013
by
fred
Browse files
update homepage to use new soundfile template
parent
0e9f806e
Changes
2
Hide whitespace changes
Inline
Side-by-side
panikweb/views.py
View file @
2a344dd7
...
...
@@ -414,8 +414,8 @@ class Home(TemplateView):
'datetime'
:
datetime
(
2007
,
1
,
day
+
1
)})
context
[
'days'
]
=
days
context
[
'
episodes'
]
=
Episod
e
.
objects
.
prefetch_related
(
'emission__categories'
).
filter
(
soundfile__
podcastable
=
True
,
soundfile__
fragment
=
False
)
\
context
[
'
soundfiles'
]
=
SoundFil
e
.
objects
.
prefetch_related
(
'
episode__
emission__categories'
).
filter
(
podcastable
=
True
,
fragment
=
False
)
\
.
select_related
().
extra
(
select
=
{
'first_diffusion'
:
'emissions_diffusion.datetime'
,
},
select_params
=
(
False
,
True
),
...
...
@@ -424,17 +424,6 @@ class Home(TemplateView):
WHERE episode_id = emissions_episode.id)'''
],
tables
=
[
'emissions_diffusion'
],).
order_by
(
'-first_diffusion'
)
[:
6
]
# 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
[
'newsletter_form'
]
=
SubscribeForm
()
return
context
...
...
panikweb_templates/templates/home.html
View file @
2a344dd7
...
...
@@ -28,9 +28,9 @@
<div
class=
"wrapper"
>
<h2><a
href=
"{% url 'listen' %}"
>
Derniers sons
</a></h2>
<ul
class=
"custom columns list"
>
{% for
episode in episod
es %}
<li
class=
"item {% if episode.emission.categories.all.count = 0 %}nocat{% endif %} {% for category in episode.emission.categories.all %} {{ category|slugify }}{% endfor %}"
>
{%
episod
e_resume
model="inline" klass="standalone"%}
{% for
soundfile in soundfil
es %}
<li
class=
"item {% if
soundfile.
episode.emission.categories.all.count = 0 %}nocat{% endif %} {% for category in
soundfile.
episode.emission.categories.all %} {{ category|slugify }}{% endfor %}"
>
{%
soundfil
e_resume
soundfile=soundfile date=soundfile.first_diffusion %}
</li>
{% endfor %}
</ul>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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