diff --git a/icalexport.py b/icalexport.py index 2f5c3ad9a799b36a0c27c28ef148ae7de39e46c2..af40aed88fd1c69375939ff179ed790fa16fa5f3 100644 --- a/icalexport.py +++ b/icalexport.py @@ -52,6 +52,28 @@ def ical_all(): 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') +@app.route('/internal/ical/user/<int:user>') +@calperm +def ical_user(user): + username = query('SELECT name FROM users WHERE users.id = ?', user)[0]['name'] + return export_lectures(query('''SELECT lectures.*, "course" AS sep, courses.* + FROM lectures + 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) + +@app.route('/internal/ical/notuser/<int:user>') +@calperm +def ical_notuser(user): + username = query('SELECT name FROM users WHERE users.id = ?', user)[0]['name'] + return export_lectures(query('''SELECT lectures.*, "course" AS sep, courses.* + FROM lectures + 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) + @app.route('/internal/ical/course/<course>') @calperm def ical_course(course):