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
7cd46306
Commit
7cd46306
authored
7 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Refactured ical export to use new responsible schema
parent
ffad2ba1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
icalexport.py
+18
-6
18 additions, 6 deletions
icalexport.py
with
18 additions
and
6 deletions
icalexport.py
+
18
−
6
View file @
7cd46306
...
...
@@ -3,17 +3,21 @@ import icalendar
from
werkzeug.datastructures
import
Headers
from
datetime
import
timedelta
,
datetime
def
export_lectures
(
lectures
,
name
):
def
export_lectures
(
lectures
,
responsible
,
name
):
cal
=
icalendar
.
Calendar
()
cal
.
add
(
'
prodid
'
,
'
-//Video AG//rwth.video//
'
)
cal
.
add
(
'
version
'
,
'
1.0
'
)
for
l
in
lectures
:
resp
=
[]
for
r
in
responsible
:
if
r
[
'
course_id
'
]
==
l
[
'
course_id
'
]:
resp
.
append
(
r
[
'
realname
'
])
event
=
icalendar
.
Event
()
event
.
add
(
'
summary
'
,
l
[
'
course
'
][
'
short
'
]
+
'
:
'
+
l
[
'
title
'
])
event
.
add
(
'
description
'
,
'
\n\n
'
.
join
([
s
for
s
in
[
l
[
'
comment
'
],
l
[
'
internal
'
],
'
Zuständig:
'
+
l
[
'
course
'
][
'
responsible
'
]
if
l
[
'
course
'
][
'
responsible
'
]
else
''
'
Zuständig:
'
+
'
,
'
.
join
(
resp
)
if
resp
else
''
]
if
s
]))
event
.
add
(
'
uid
'
,
'
%i@rwth.video
'
%
l
[
'
id
'
])
event
.
add
(
'
dtstamp
'
,
datetime
.
utcnow
())
...
...
@@ -45,12 +49,17 @@ def calperm(func):
return
Response
(
"
Login required
"
,
401
,
{
'
WWW-Authenticate
'
:
'
Basic realm=
"
FS-Login required
"'
})
return
decorator
def
get_responsible
():
return
query
(
'''
SELECT users.*, responsible.course_id FROM responsible
JOIN users ON users.id = responsible.user_id
'''
)
@app.route
(
'
/internal/ical/all
'
)
@calperm
def
ical_all
():
return
export_lectures
(
query
(
'''
SELECT lectures.*,
"
course
"
AS sep, courses.*
FROM lectures JOIN courses ON courses.id = lectures.course_id
WHERE NOT norecording AND NOT external ORDER BY time DESC LIMIT 1000
'''
),
'
videoag_all.ics
'
)
WHERE NOT norecording AND NOT external ORDER BY time DESC LIMIT 1000
'''
),
get_responsible
(),
'
videoag_all.ics
'
)
@app.route
(
'
/internal/ical/user/<int:user>
'
)
@calperm
...
...
@@ -61,7 +70,8 @@ def ical_user(user):
JOIN courses ON courses.id = lectures.course_id
JOIN responsible ON responsible.course_id = courses.id
WHERE NOT norecording AND NOT external AND responsible.user_id = ?
ORDER BY time DESC LIMIT 1000
'''
,
user
),
'
videoag_%s.ics
'
%
username
)
ORDER BY time DESC LIMIT 1000
'''
,
user
),
get_responsible
(),
'
videoag_%s.ics
'
%
username
)
@app.route
(
'
/internal/ical/notuser/<int:user>
'
)
@calperm
...
...
@@ -72,11 +82,13 @@ def ical_notuser(user):
JOIN courses ON courses.id = lectures.course_id
LEFT JOIN responsible ON (responsible.course_id = courses.id AND responsible.user_id = ?)
WHERE NOT norecording AND NOT external AND responsible.user_id IS NULL
ORDER BY time DESC LIMIT 1000
'''
,
user
),
'
videoag_not_%s.ics
'
%
username
)
ORDER BY time DESC LIMIT 1000
'''
,
user
),
get_responsible
(),
'
videoag_not_%s.ics
'
%
username
)
@app.route
(
'
/internal/ical/course/<course>
'
)
@calperm
def
ical_course
(
course
):
return
export_lectures
(
query
(
'''
SELECT lectures.*,
"
course
"
AS sep, courses.*
FROM lectures JOIN courses ON courses.id = lectures.course_id
WHERE courses.handle = ? AND NOT norecording AND NOT external ORDER BY time DESC
'''
,
course
),
'
videoag_course_
'
+
course
+
'
.ics
'
)
WHERE courses.handle = ? AND NOT norecording AND NOT external ORDER BY time DESC
'''
,
course
),
get_responsible
(),
'
videoag_%s.ics
'
%
course
)
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