Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
panikweb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
panikweb
Commits
a80082cc
Commit
a80082cc
authored
Sep 07, 2013
by
Simon Daron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recent listen on home
@fred
request perf check
parent
59586851
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
panikweb/views.py
panikweb/views.py
+22
-0
panikweb_templates/templates/home.html
panikweb_templates/templates/home.html
+8
-0
No files found.
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
Markdown
is supported
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