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
6bb795de
Commit
6bb795de
authored
Aug 29, 2013
by
fred
Browse files
grid: do not put the same emission twice in the same cell
parent
b099ddac
Changes
2
Hide whitespace changes
Inline
Side-by-side
panikweb/views.py
View file @
6bb795de
...
...
@@ -192,7 +192,33 @@ class Grid(TemplateView):
# start grid after the night programs
grid
=
grid
[
2
*
Schedule
.
DAY_HOUR_START
:]
+
grid
[:
2
*
Schedule
.
DAY_HOUR_START
]
# merge adjacent cells
# look for the case where the same emission has different schedules for
# the same time cell, for example if it lasts one hour the first week,
# and two hours the third week.
for
i
in
range
(
nb_lines
):
grid
[
i
]
=
[
x
for
x
in
grid
[
i
]
if
x
is
not
None
]
for
j
,
cell
in
enumerate
(
grid
[
i
]):
if
grid
[
i
][
j
]
is
None
:
continue
if
len
(
grid
[
i
][
j
].
schedules
)
>
1
:
time_cell_emissions
=
{}
for
schedule
in
grid
[
i
][
j
].
schedules
:
if
not
schedule
.
emission
.
id
in
time_cell_emissions
:
time_cell_emissions
[
schedule
.
emission
.
id
]
=
[]
time_cell_emissions
[
schedule
.
emission
.
id
].
append
(
schedule
)
for
schedule_list
in
time_cell_emissions
.
values
():
if
len
(
schedule_list
)
==
1
:
continue
# here it is, same cell, same emission, several
# schedules
schedule_list
.
sort
(
lambda
x
,
y
:
-
cmp
(
x
.
get_duration
(),
y
.
get_duration
()))
for
schedule
in
schedule_list
[
1
:]:
grid
[
i
][
j
].
schedules
.
remove
(
schedule
)
end_time
=
schedule
.
datetime
+
timedelta
(
minutes
=
schedule
.
get_duration
())
schedule_list
[
0
].
time_label_extra
=
', -%02d:%02d %s'
%
(
end_time
.
hour
,
end_time
.
minute
,
schedule
.
weeks_string
)
# merge adjacent
# 1st thing is to merge cells on the same line, this will mostly catch
# consecutive nonstop cells
...
...
panikweb_templates/templates/grid.html
View file @
6bb795de
...
...
@@ -45,6 +45,9 @@
{% if schedule.weeks_string %}
<span>
{{ schedule.weeks_string }}
</span>
{% endif %}
{% if schedule.time_label_extra %}
<span>
{{ schedule.time_label_extra }}
</span>
{% endif %}
<span>
)
</span>
{% endspaceless %}
{% endif %}
...
...
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