Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Video AG Infrastruktur
website
Commits
c66e085f
Commit
c66e085f
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
moved schedule to own module
parent
dbfa4904
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
schedule.py
+57
-0
57 additions, 0 deletions
schedule.py
server.py
+1
-56
1 addition, 56 deletions
server.py
with
58 additions
and
56 deletions
schedule.py
0 → 100755
+
57
−
0
View file @
c66e085f
from
server
import
*
@app.route
(
'
/schedule
'
)
@register_navbar
(
'
Drehplan
'
,
'
calendar
'
)
@mod_required
def
schedule
():
if
'
kw
'
not
in
request
.
args
:
kw
=
0
else
:
kw
=
int
(
request
.
args
[
'
kw
'
])
start
=
date
.
today
()
-
timedelta
(
days
=
date
.
today
().
weekday
()
-
7
*
kw
)
days
=
[{
'
date
'
:
start
,
'
lectures
'
:
[],
'
atonce
'
:
0
,
'
index
'
:
0
}]
earlieststart
=
time
(
23
,
59
)
latestend
=
time
(
0
,
0
)
for
i
in
range
(
1
,
7
):
days
.
append
({
'
date
'
:
days
[
i
-
1
][
'
date
'
]
+
timedelta
(
days
=
1
),
'
atonce
'
:
0
,
'
index
'
:
i
,
'
lectures
'
:[]
})
for
i
in
days
:
# date and times are burning in sqlite
s
=
datetime
.
combine
(
i
[
'
date
'
],
time
())
e
=
datetime
.
combine
(
i
[
'
date
'
],
time
(
23
,
59
))
i
[
'
lectures
'
]
=
query
(
'''
SELECT lectures.*,courses.short
FROM lectures
JOIN courses ON (lectures.course_id = courses.id)
WHERE (time < ?) AND (time > ?)
ORDER BY time ASC
'''
,
e
,
s
);
# sweepline to find out how many lectures overlap
maxcol
=
0
;
curcol
=
0
;
freecol
=
[];
for
l
in
i
[
'
lectures
'
]:
# who the hell inserts lectures with zero length?!?!?
l
[
'
time_end
'
]
=
l
[
'
time
'
]
+
timedelta
(
minutes
=
max
(
l
[
'
duration
'
],
1
))
for
l
in
sorted
([(
l
[
'
time
'
],
True
,
l
)
for
l
in
i
[
'
lectures
'
]]
+
[(
l
[
'
time_end
'
],
False
,
l
)
for
l
in
i
[
'
lectures
'
]],
key
=
lambda
t
:(
t
[
0
],
t
[
1
])):
if
l
[
1
]:
curcol
+=
1
if
curcol
>
maxcol
:
maxcol
=
curcol
if
len
(
freecol
)
==
0
:
freecol
.
append
(
maxcol
)
l
[
2
][
'
schedule_col
'
]
=
freecol
.
pop
()
if
earlieststart
>
l
[
0
].
time
():
earlieststart
=
l
[
0
].
time
()
else
:
curcol
-=
1
freecol
.
append
(
l
[
2
][
'
schedule_col
'
])
if
latestend
<
l
[
0
].
time
():
latestend
=
l
[
0
].
time
()
i
[
'
maxcol
'
]
=
max
(
maxcol
,
1
)
times
=
[]
s
=
min
(
earlieststart
,
time
(
8
,
0
))
e
=
max
(
latestend
,
time
(
19
,
0
))
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
(
'
schedule.html
'
,
days
=
days
,
times
=
times
,
kw
=
kw
)
This diff is collapsed.
Click to expand it.
server.py
+
1
−
56
View file @
c66e085f
...
...
@@ -317,62 +317,6 @@ def auth(): # For use with nginx auth_request
return
Response
(
"
Login required
"
,
401
,
{
'
WWW-Authenticate
'
:
'
Basic realm=
"
Login Required
"'
})
return
"
Not allowed
"
,
403
@app.route
(
'
/schedule
'
)
@register_navbar
(
'
Drehplan
'
,
'
calendar
'
)
@mod_required
def
schedule
():
if
'
kw
'
not
in
request
.
args
:
kw
=
0
else
:
kw
=
int
(
request
.
args
[
'
kw
'
])
start
=
date
.
today
()
-
timedelta
(
days
=
date
.
today
().
weekday
()
-
7
*
kw
)
days
=
[{
'
date
'
:
start
,
'
lectures
'
:
[],
'
atonce
'
:
0
,
'
index
'
:
0
}]
earlieststart
=
time
(
23
,
59
)
latestend
=
time
(
0
,
0
)
for
i
in
range
(
1
,
7
):
days
.
append
({
'
date
'
:
days
[
i
-
1
][
'
date
'
]
+
timedelta
(
days
=
1
),
'
atonce
'
:
0
,
'
index
'
:
i
,
'
lectures
'
:[]
})
for
i
in
days
:
# date and times are burning in sqlite
s
=
datetime
.
combine
(
i
[
'
date
'
],
time
())
e
=
datetime
.
combine
(
i
[
'
date
'
],
time
(
23
,
59
))
i
[
'
lectures
'
]
=
query
(
'''
SELECT lectures.*,courses.short
FROM lectures
JOIN courses ON (lectures.course_id = courses.id)
WHERE (time < ?) AND (time > ?)
ORDER BY time ASC
'''
,
e
,
s
);
# sweepline to find out how many lectures overlap
maxcol
=
0
;
curcol
=
0
;
freecol
=
[];
for
l
in
i
[
'
lectures
'
]:
# who the hell inserts lectures with zero length?!?!?
l
[
'
time_end
'
]
=
l
[
'
time
'
]
+
timedelta
(
minutes
=
max
(
l
[
'
duration
'
],
1
))
for
l
in
sorted
([(
l
[
'
time
'
],
True
,
l
)
for
l
in
i
[
'
lectures
'
]]
+
[(
l
[
'
time_end
'
],
False
,
l
)
for
l
in
i
[
'
lectures
'
]],
key
=
lambda
t
:(
t
[
0
],
t
[
1
])):
if
l
[
1
]:
curcol
+=
1
if
curcol
>
maxcol
:
maxcol
=
curcol
if
len
(
freecol
)
==
0
:
freecol
.
append
(
maxcol
)
l
[
2
][
'
schedule_col
'
]
=
freecol
.
pop
()
if
earlieststart
>
l
[
0
].
time
():
earlieststart
=
l
[
0
].
time
()
else
:
curcol
-=
1
freecol
.
append
(
l
[
2
][
'
schedule_col
'
])
if
latestend
<
l
[
0
].
time
():
latestend
=
l
[
0
].
time
()
i
[
'
maxcol
'
]
=
max
(
maxcol
,
1
)
times
=
[]
s
=
min
(
earlieststart
,
time
(
8
,
0
))
e
=
max
(
latestend
,
time
(
19
,
0
))
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
(
'
schedule.html
'
,
days
=
days
,
times
=
times
,
kw
=
kw
)
@app.route
(
'
/stats
'
)
@register_navbar
(
'
Statistiken
'
,
'
stats
'
)
@mod_required
...
...
@@ -407,3 +351,4 @@ def suggest_chapter(lectureid):
import
feeds
import
importer
import
schedule
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment