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
Simon Daron
panikweb
Commits
95b0d81e
Commit
95b0d81e
authored
Aug 25, 2013
by
fred
Browse files
add time labels when it doesn't match actual cell
parent
2a269ef5
Changes
2
Hide whitespace changes
Inline
Side-by-side
panikweb/views.py
View file @
95b0d81e
...
...
@@ -191,12 +191,28 @@ class Grid(TemplateView):
# this handles case A (see comment above)
for
schedule
in
current_cell_schedules
:
if
schedule
in
same_cell_below
.
schedules
:
print
'removing schedule:'
,
schedule
same_cell_below
.
schedules
.
remove
(
schedule
)
elif
same_cell_below
.
schedules
and
\
current_cell_schedules
.
issuperset
(
same_cell_below
.
schedules
):
# this handles case B (see comment above)
# we set the cell time label to the longest
# period
grid
[
i
][
j
].
time_label
=
same_cell_below
.
time_label
# then we sort emissions so the longest are
# put first
grid
[
i
][
j
].
schedules
.
sort
(
lambda
x
,
y
:
-
cmp
(
x
.
get_duration
(),
y
.
get_duration
()))
# then we add individual time labels to the
# other schedules
for
schedule
in
current_cell_schedules
:
if
schedule
not
in
same_cell_below
.
schedules
:
end_time
=
schedule
.
datetime
+
timedelta
(
minutes
=
schedule
.
get_duration
())
schedule
.
time_label
=
'%02d:%02d-%02d:%02d'
%
(
schedule
.
datetime
.
hour
,
schedule
.
datetime
.
minute
,
end_time
.
hour
,
end_time
.
minute
)
grid
[
i
][
j
].
h
+=
1
grid
[
i
+
cursor
].
remove
(
same_cell_below
)
cursor
+=
1
...
...
panikweb_templates/templates/grid.html
View file @
95b0d81e
...
...
@@ -47,8 +47,19 @@
<strong>
<a
href=
"{% url 'emission-view' slug=schedule.emission.slug %}"
>
{{ schedule.emission.title }}
</a>
</strong>
<br
/>
{% if schedule.weeks_string %}
({{ schedule.weeks_string }})
<br
/>
{% if schedule.weeks_string or schedule.time_label %}
{% spaceless %}
<span>
(
</span>
{% if schedule.time_label %}
<span>
{{ schedule.time_label }}
</span>
{% if schedule.weeks_string %}
<span>
,
</span>
{% endif %}
{% endif %}
{% if schedule.weeks_string %}
<span>
{{ schedule.weeks_string }}
</span>
{% endif %}
<span>
)
</span>
{% endspaceless %}
{% endif %}
</div>
{% endfor %}
...
...
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