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
a80082cc
Commit
a80082cc
authored
Sep 07, 2013
by
Simon Daron
Browse files
Recent listen on home
@fred
request perf check
parent
59586851
Changes
2
Hide whitespace changes
Inline
Side-by-side
panikweb/views.py
View file @
a80082cc
...
...
@@ -384,6 +384,28 @@ class Home(TemplateView):
days
.
append
({
'schedules'
:
[
x
for
x
in
schedules
if
x
.
is_on_weekday
(
day
+
1
)],
'datetime'
:
datetime
(
2007
,
1
,
day
+
1
)})
context
[
'days'
]
=
days
context
[
'episodes'
]
=
Episode
.
objects
.
filter
(
soundfile__podcastable
=
True
,
soundfile__fragment
=
False
)
\
.
select_related
().
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'
)
[:
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
)
return
context
home
=
Home
.
as_view
()
...
...
panikweb_templates/templates/home.html
View file @
a80082cc
...
...
@@ -12,6 +12,14 @@
<div
class=
"wrapper"
>
<h2>
Cette semaine sur Panik
</h2>
{% weekview %}
<h2>
Ecouter
</h2>
<ul
class=
"custom columns list"
>
{% for episode in episodes %}
<li
class=
"item {% if episode.emission.categories.all.count = 0 %}nocat{% endif %} {% for category in episode.emission.categories.all %} {{ category|slugify }}{% endfor %}"
>
{% episode_resume model="inline" klass="standalone"%}
</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
...
...
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