Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
621f4936
Commit
621f4936
authored
Jul 25, 2017
by
Andreas Valder
Browse files
added the option for the timetable to select a date or pass a date as parameter
parent
efdffeef
Changes
2
Hide whitespace changes
Inline
Side-by-side
templates/timetable.html
View file @
621f4936
...
...
@@ -7,20 +7,28 @@
<a
class=
"pull-right fa fa-calendar"
aria-hidden=
"true"
href=
"{{url_for('ical_all')}}"
style=
"text-decoration: none"
></a>
</h1>
</div>
<div
class=
"
row
hidden-print"
>
<div
style=
"margin-top: 10px;"
class=
"col-xs-12"
>
<div
class=
"hidden-print"
>
<div
style=
"margin-top: 10px;
padding: 15px;
"
class=
"col-xs-12"
>
<a
href=
"{{url_for('timetable', kw=kw-1) }}"
class=
"pull-left btn btn-default"
>
{{ "
<
<"
}}</
a
>
<a
href=
"{{url_for('timetable', kw=kw+1) }}"
class=
"pull-right btn btn-default"
>
{{ ">>" }}
</a>
<a
href=
"{{url_for('timetable', kw=0) }}"
style=
"width: 80px;"
class=
"
center-block
btn btn-default"
>
today
</a>
<a
href=
"{{url_for('timetable', kw=0) }}"
style=
"width: 80px;"
class=
"btn btn-default
center-block
"
>
today
</a>
</div>
<input
id=
"weeksel"
type=
"week"
class=
"center-block"
value=
"{{ weekofyear }}"
/>
<script>
$
(
function
()
{
$
(
"
#weeksel
"
).
on
(
"
change
"
,
function
()
{
window
.
location
.
href
=
"
{{ url_for('timetable') }}?date=
"
+
$
(
"
#weeksel
"
).
val
()
});
});
</script>
</div>
<div
class=
"panel-body row table-responsive"
style=
"margin-left: 0px; margin-right: 0px; padding-left: 0px; padding-right: 0px"
>
<div
class=
"panel-body row table-responsive"
>
<table
id=
"timetable"
class=
"table table-bordered col-xs-12"
style=
"width: auto; min-width: 100%;"
>
<tr><th
style=
"width: 30px;"
></th>
{% for d in days if (d.index
<
5)
or
(
d.lectures
|
length
)
>
0 %}
<th
style=
"min-width: 10em;"
colspan=
"{{d.maxcol}}"
>
{{ d.date.strftime("%A (%d.%m.%Y)") }}
</th>
{% endfor %}
</tr>
{# iterating over each 15 min block #}
{% for t in times %}
{% set time_index = loop.index %}
<tr
height=
"12px"
{%
if
t.strftime
("%
M
"
) =
=
"00"
%}
class=
"hourlytime"
{%
endif
%}
>
<tr
{%
if
t.strftime
("%
M
"
) =
=
"00"
%}
class=
"hourlytime"
{%
endif
%}
>
{# display time in first row if its a full hour #}
{% if ((time_index - 1) is divisibleby 4) %}
<td
rowspan=
"4"
style=
"vertical-align: top;"
>
{{ t.strftime("%H:%M") }}
</td>
{% endif %}
{# iterate over days if if it is a working day or we have lectures on that day (optionaly skip weekends) #}
...
...
@@ -72,6 +80,5 @@
</div>
</div>
</div>
</div>
{% endblock %}
timetable.py
View file @
621f4936
...
...
@@ -5,7 +5,29 @@ from server import *
@
mod_required
def
timetable
():
if
'kw'
not
in
request
.
args
:
kw
=
0
if
'date'
in
request
.
args
:
thisweekmonday
=
datetime
.
now
()
thisweekmonday
-=
timedelta
(
days
=
thisweekmonday
.
weekday
())
try
:
datesweekmonday
=
datetime
.
strptime
(
request
.
args
[
'date'
],
'%d-%m-%Y'
)
except
ValueError
:
datesweekmonday
=
None
if
not
datesweekmonday
:
try
:
datesweekmonday
=
datetime
.
strptime
(
request
.
args
[
'date'
]
+
'-1'
,
"%Y-W%W-%w"
)
except
ValueError
:
datesweekmonday
=
None
if
not
datesweekmonday
:
kw
=
0
weekofyear
=
str
(
datetime
.
today
().
year
)
+
"-W"
+
str
(
datetime
.
today
().
isocalendar
()[
1
])
else
:
datesweekmonday
-=
timedelta
(
days
=
datesweekmonday
.
weekday
())
weekofyear
=
str
(
datesweekmonday
.
year
)
+
"-W"
+
str
(
datesweekmonday
.
isocalendar
()[
1
])
kw
=
int
((
datesweekmonday
.
date
()
-
thisweekmonday
.
date
()).
days
/
7
)
else
:
kw
=
0
else
:
kw
=
int
(
request
.
args
[
'kw'
])
try
:
...
...
@@ -79,4 +101,4 @@ def timetable():
for
i
in
range
(
s
.
hour
*
4
,
min
(
int
((
60
*
e
.
hour
/
15
)
/
4
)
*
4
+
5
,
24
*
4
)):
t
=
i
*
15
times
.
append
(
time
(
int
(
t
/
60
),
t
%
60
))
return
render_template
(
'timetable.html'
,
days
=
days
,
times
=
times
,
kw
=
kw
)
return
render_template
(
'timetable.html'
,
days
=
days
,
times
=
times
,
kw
=
kw
,
weekofyear
=
weekofyear
)
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