Commit 235aaecc authored by Andreas Valder's avatar Andreas Valder
Browse files

added a stats page

parent 23252268
......@@ -66,7 +66,7 @@ def index():
@app.route('/course')
@register_navbar('Videos', icon='film')
def videos():
def course():
courses = query('SELECT * FROM courses WHERE (? OR (visible AND listed))', ismod())
for course in courses:
if course['semester'] == '':
......@@ -76,6 +76,24 @@ def videos():
groupedby = 'semester'
return render_template('course.html', courses=courses, groupedby=groupedby)
@app.route('/course/<id>')
def course_id(id):
courses = query('SELECT * FROM courses WHERE ((handle = ?) or id = ?) AND (? OR visible)', id, id, ismod())
if not courses:
flash('Diese Veranstaltung existiert nicht!')
return app.view_functions['videos'](), 404
lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible)', courses[0]['id'], ismod())
videos = query('''
SELECT videos.*, (videos.downloadable AND courses.downloadable) as downloadable, formats.description AS format_description
FROM videos
JOIN lectures ON (videos.lecture_id = lectures.id)
JOIN formats ON (videos.video_format = formats.id)
JOIN courses ON (lectures.course_id = courses.id)
WHERE lectures.course_id= ? AND (? OR videos.visible)
ORDER BY lectures.time, formats.prio DESC
''', courses[0]['id'], ismod())
return render_template('course_id.html', course=courses[0], lectures=lectures, videos=videos)
@app.route('/faq')
@register_navbar('FAQ', icon='question-sign')
def faq():
......@@ -109,24 +127,6 @@ def search():
'WHERE (? OR (coursevisible AND listed AND visible)) GROUP BY id ORDER BY _score DESC, time DESC LIMIT 30', ismod())
return render_template('search.html', searchtext=request.args['q'], courses=courses, lectures=lectures)
@app.route('/course/<id>')
def course(id):
courses = query('SELECT * FROM courses WHERE ((handle = ?) or id = ?) AND (? OR visible)', id, id, ismod())
if not courses:
flash('Diese Veranstaltung existiert nicht!')
return app.view_functions['videos'](), 404
lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible)', courses[0]['id'], ismod())
videos = query('''
SELECT videos.*, (videos.downloadable AND courses.downloadable) as downloadable, formats.description AS format_description
FROM videos
JOIN lectures ON (videos.lecture_id = lectures.id)
JOIN formats ON (videos.video_format = formats.id)
JOIN courses ON (lectures.course_id = courses.id)
WHERE lectures.course_id= ? AND (? OR videos.visible)
ORDER BY lectures.time, formats.prio DESC
''', courses[0]['id'], ismod())
return render_template('course_id.html', course=courses[0], lectures=lectures, videos=videos)
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'GET':
......@@ -243,3 +243,9 @@ def schedule():
times.append(time(int(t/60),t%60))
return render_template('schedule.html',days=days,times=times)
@app.route('/stats')
@register_navbar('Statistiken', 'stats')
@mod_required
def stats():
return render_template('stats.html')
{% from 'macros.html' import preview %}
{% extends "base.html" %}
{% block content %}
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Statistiken</h1>
</div>
<div class="panel-body">
</div>
</div>
</div>
{% endblock %}
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