Commit d8ec3c15 authored by Julian Rother's avatar Julian Rother
Browse files

Add permission data to course and lectures data in course endpoint

parent 7325c1cc
......@@ -146,10 +146,17 @@ def courses():
@handle_errors('courses', 'Diese Veranstaltung existiert nicht!', 404, IndexError)
def course(id=None, handle=None):
if id:
courses = query('SELECT * FROM courses WHERE id = ? AND (? OR visible)', id, ismod())[0]
course = query('SELECT * FROM courses WHERE id = ? AND (? OR visible)', id, ismod())[0]
else:
courses = query('SELECT * FROM courses WHERE handle = ? AND (? OR visible)', handle, ismod())[0]
lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible)', courses['id'], ismod())
course = query('SELECT * FROM courses WHERE handle = ? AND (? OR visible)', handle, ismod())[0]
course['auth'] = query('SELECT * FROM auth WHERE course_id = ?', course['id'])
auths = query('SELECT auth.* FROM auth JOIN lectures ON (auth.lecture_id = lectures.id) WHERE lectures.course_id = ?', course['id'])
lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible)', course['id'], ismod())
for lecture in lectures:
lecture['auth'] = []
for auth in auths:
if auth['lecture_id'] == lecture['id']:
lecture['auth'].append(auth)
videos = query('''
SELECT videos.*, (videos.downloadable AND courses.downloadable) as downloadable, formats.description AS format_description
FROM videos
......@@ -158,8 +165,8 @@ def course(id=None, handle=None):
JOIN courses ON (lectures.course_id = courses.id)
WHERE lectures.course_id= ? AND (? OR videos.visible)
ORDER BY lectures.time, formats.prio DESC
''', courses['id'], ismod())
return render_template('course.html', course=courses, lectures=lectures, videos=videos)
''', course['id'], ismod())
return render_template('course.html', course=course, lectures=lectures, videos=videos)
@app.route('/faq')
@register_navbar('FAQ', icon='question-sign')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment