...
 
Commits (2)
......@@ -31,9 +31,11 @@ unittest: &unittest
- .coverage
- report.txt
unittest_buster:
<<: *unittest
image: debian:buster
# Buster is not supported for now
#
#unittest_buster:
# <<: *unittest
# image: debian:buster
livetest:
image: debian:stretch
......
......@@ -7,15 +7,21 @@ from datetime import time
@app.route('/internal/user/<int:user>/cutprogress', endpoint='cutprogress_user')
@mod_required
def cutprogress(user=None):
allsemester = query('SELECT DISTINCT semester from courses ORDER BY semester DESC');
allsemester = query('SELECT DISTINCT semester from courses ORDER BY semester DESC')
semester = request.values.get('semester', allsemester[0]['semester'])
coursesraw = query('SELECT courses.id, courses.handle, courses.short FROM courses WHERE semester = ?', semester)
courses = []
maxlecturecount = 0
for course in coursesraw:
course['lectures'] = query('SELECT lectures.title, lectures.time, lectures.id FROM lectures WHERE lectures.course_id= ? AND NOT lectures.deleted AND NOT lectures.norecording ORDER BY lectures.time', course['id'])
course['lectures'] = query('''
SELECT lectures.title, lectures.time, lectures.id FROM lectures
WHERE lectures.course_id= ? AND NOT lectures.deleted AND NOT lectures.norecording
ORDER BY lectures.time''', course['id'])
for lecture in course['lectures']:
lecture['videos'] = query('SELECT videos.path, formats.description as formatdesc, videos.visible FROM videos JOIN formats ON (videos.video_format = formats.id) WHERE videos.lecture_id = ? AND NOT videos.deleted', lecture['id'])
lecture['videos'] = query('''
SELECT videos.path, formats.description as formatdesc, videos.visible FROM videos
JOIN formats ON (videos.video_format = formats.id)
WHERE videos.lecture_id = ? AND NOT videos.deleted''', lecture['id'])
course['responsible'] = query('''SELECT users.*
FROM responsible
JOIN users ON (responsible.user_id = users.id AND responsible.course_id = ?)
......@@ -24,5 +30,10 @@ def cutprogress(user=None):
course['responsible'] = [{"realname": "Niemand", "id": -1}]
if not user or user in [ r['id'] for r in course['responsible'] ]:
courses.append(course)
maxlecturecount = max(len(course['lectures']),maxlecturecount)
return render_template('cutprogress.html', allsemester=allsemester, semester=semester, courses=courses, maxlecturecount=maxlecturecount, user=query('SELECT * FROM users WHERE id = ?', user)[0] if user else None)
maxlecturecount = max(len(course['lectures']), maxlecturecount)
return render_template('cutprogress.html',
allsemester=allsemester,
semester=semester,
courses=courses,
maxlecturecount=maxlecturecount,
user=query('SELECT * FROM users WHERE id = ?', user)[0] if user else None)
......@@ -51,7 +51,13 @@ elif config['DB_ENGINE'] == 'mysql':
def get_dbcursor():
if 'db' not in g or not g.db.is_connected():
g.db = mysql.connector.connect(user=config['MYSQL_USER'], password=config['MYSQL_PASSWD'], host=config.get('MYSQL_HOST', None), port=config.get('MYSQL_PORT', 3306), unix_socket=config.get('MYSQL_UNIX', None), database=config['MYSQL_DB'])
g.db = mysql.connector.connect(
user=config['MYSQL_USER'],
password=config['MYSQL_PASSWD'],
host=config.get('MYSQL_HOST', None),
port=config.get('MYSQL_PORT', 3306),
unix_socket=config.get('MYSQL_UNIX', None),
database=config['MYSQL_DB'])
if not hasattr(request, 'db'):
request.db = g.db.cursor()
return request.db
......