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

Basic integration of video permission errors into player page (#48)

parent bc071d3e
...@@ -129,8 +129,8 @@ def authdescr(auths): ...@@ -129,8 +129,8 @@ def authdescr(auths):
return 'rwth', 'Nur für RWTH-Angehörige verfügbar' return 'rwth', 'Nur für RWTH-Angehörige verfügbar'
if l2p_courses: if l2p_courses:
if password: if password:
return 'rwth', 'Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar' return 'l2p', 'Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar'
return 'rwth', 'Nur für Teilnehmer der Veranstaltung verfügbar' return 'l2p', 'Nur für Teilnehmer der Veranstaltung verfügbar'
if password: if password:
return 'password', 'Nur für Nutzer mit Passwort verfügbar' return 'password', 'Nur für Nutzer mit Passwort verfügbar'
return 'public', 'Öffentlich verfügbar' return 'public', 'Öffentlich verfügbar'
...@@ -295,12 +295,22 @@ def lecture(id): ...@@ -295,12 +295,22 @@ def lecture(id):
WHERE videos.lecture_id = ? AND (? OR videos.visible) WHERE videos.lecture_id = ? AND (? OR videos.visible)
ORDER BY formats.prio DESC ORDER BY formats.prio DESC
''', lecture['course_id'], lecture['id'], ismod()) ''', lecture['course_id'], lecture['id'], ismod())
auths = query('SELECT auth.* FROM auth WHERE (auth.lecture_id = ? OR auth.course_id = ?)',
lecture['id'], lecture['course_id'])
if not videos: if not videos:
flash('Zu dieser Vorlesung wurden noch keine Videos veröffentlicht!') flash('Zu dieser Vorlesung wurden noch keine Videos veröffentlicht!')
course = query('SELECT * FROM courses WHERE id = ? AND (? OR (visible AND listed))', lecture['course_id'], ismod())[0] course = query('SELECT * FROM courses WHERE id = ? AND (? OR (visible AND listed))', lecture['course_id'], ismod())[0]
if not course: if not course:
return render_endpoint('course', 'Diese Veranstaltung existiert nicht!'), 404 return render_endpoint('course', 'Diese Veranstaltung existiert nicht!'), 404
chapters = query('SELECT * FROM chapters WHERE lecture_id = ? AND NOT deleted AND (? OR visible) ORDER BY time ASC', id, ismod()) chapters = query('SELECT * FROM chapters WHERE lecture_id = ? AND NOT deleted AND (? OR visible) ORDER BY time ASC', id, ismod())
if not checkauth(auths):
mode, text = authdescr(auths)
if mode == 'rwth':
flash(text+'. <a target="_blank" href="'+url_for('start_rwthauth')+'">Hier authorisieren</a>.')
elif mode == 'l2p':
flash(text+'. <a target="_blank" href="'+url_for('start_l2pauth')+'">Hier authorisieren</a>.')
else:
flash(text+'.')
return render_template('embed.html' if request.endpoint == 'embed' else 'lecture.html', course=course, lecture=lecture, videos=videos, chapters=chapters) return render_template('embed.html' if request.endpoint == 'embed' else 'lecture.html', course=course, lecture=lecture, videos=videos, chapters=chapters)
...@@ -436,6 +446,7 @@ def auth(): # For use with nginx auth_request ...@@ -436,6 +446,7 @@ def auth(): # For use with nginx auth_request
AND (? OR (courses.visible AND lectures.visible AND videos.visible)) AND (? OR (courses.visible AND lectures.visible AND videos.visible))
ORDER BY auth.video_id DESC, auth.lecture_id DESC, auth.course_id DESC''', ORDER BY auth.video_id DESC, auth.lecture_id DESC, auth.course_id DESC''',
url, ismod()) url, ismod())
if not videos: if not videos:
return "Not allowed", 403 return "Not allowed", 403
auth = request.authorization auth = request.authorization
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
<div class="col-xs-12 col-md-offset-{{ page_border }} col-md-{{ 12-(2*page_border) }}"> <div class="col-xs-12 col-md-offset-{{ page_border }} col-md-{{ 12-(2*page_border) }}">
{% endif %} {% endif %}
{% for msg in get_flashed_messages() %} {% for msg in get_flashed_messages() %}
<div class="hidden-print alert alert-danger" role="alert">{{ msg }}</div> <div class="hidden-print alert alert-danger" role="alert">{{ msg|safe }}</div>
{% endfor %} {% endfor %}
{% for msg in get_announcements(min_announcement_level) if (not request.cookies['alert-info-'+msg.id|string]) %} {% for msg in get_announcements(min_announcement_level) if (not request.cookies['alert-info-'+msg.id|string]) %}
<div class="hidden-print alert alert-{{levels.get(msg.level, ('info', ''))[0]}}" role="alert"> <div class="hidden-print alert alert-{{levels.get(msg.level, ('info', ''))[0]}}" role="alert">
......
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