Skip to content
Snippets Groups Projects
Commit 049dee38 authored by Andreas Valder's avatar Andreas Valder
Browse files

Merge branch 'master' of git.fsmpi.rwth-aachen.de:julianundandyfrickelnkram/videoagwebsite

parents bb943983 87e950e2
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,18 @@ CREATE TABLE IF NOT EXISTS `changelog` (
`value_new` text NOT NULL,
`executed` text NOT NULL
);
CREATE TABLE IF NOT EXISTS `chapters` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`lecture_id` INTEGER NOT NULL,
`time` INTEGER NOT NULL,
`text` text NOT NULL,
`visible` INTEGER NOT NULL DEFAULT 0,
`deleted` INTEGER NOT NULL DEFAULT 0,
`time_created` datetime NOT NULL,
`time_updated` datetime NOT NULL,
`created_by` INTEGER DEFAULT NULL,
`submitted_by` varchar(32) DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS `courses_data` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`visible` INTEGER NOT NULL,
......
......@@ -176,7 +176,8 @@ def lecture(id):
courses = query('SELECT * FROM courses WHERE id = ? AND (? OR (visible AND listed))', lectures[0]['course_id'], ismod())
if not courses:
return render_endpoint('course', 'Diese Veranstaltung existiert nicht!'), 404
return render_template('lecture.html', course=courses[0], lecture=lectures[0], videos=videos)
chapters = query('SELECT * FROM chapters WHERE lecture_id = ? AND NOT deleted AND (? OR visible) ORDER BY time ASC', id, ismod())
return render_template('lecture.html', course=courses[0], lecture=lectures[0], videos=videos, chapters=chapters)
@app.route('/search')
def search():
......@@ -218,14 +219,15 @@ def logout():
@app.route('/edit', methods=['GET', 'POST'])
@mod_required
def edit(prefix="", ignore=[]):
# All editable tables are expected to have a 'time_updated' field
tabs = {
'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short',
'handle', 'organizer', 'subject', 'semester', 'downloadable',
'internal', 'responsible','deleted']),
'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment',
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']),
'site_texts': ('site_texts', 'key', ['value']),
'videos': ('videos_data', 'id', ['visible','deleted'])
'videos': ('videos_data', 'id', ['visible','deleted']),
'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted'])
}
query('BEGIN')
if request.is_json:
......@@ -240,7 +242,7 @@ def edit(prefix="", ignore=[]):
assert table in tabs
assert column in tabs[table][2]
query('INSERT INTO changelog ("table",id_value,id_key,field,value_new,value_old,"when",who,executed) VALUES (?,?,?,?,?,(SELECT %s FROM %s WHERE %s = ?),?,?,1)'%(column,tabs[table][0],tabs[table][1]),table,id,tabs[table][1],column,val,id,datetime.now(),session['user']['givenName'])
query('UPDATE %s SET %s = ? WHERE %s = ?'%(tabs[table][0], column,tabs[table][1]), val, id)
query('UPDATE %s SET %s = ?, time_updated = ? WHERE %s = ?'%(tabs[table][0], column, tabs[table][1]), val, datetime.now(), id)
query('COMMIT')
return "OK", 200
......@@ -388,5 +390,20 @@ def changelog():
def files(filename):
return redirect(config['VIDEOPREFIX']+'/'+filename)
@app.route('/newchapter/<int:lectureid>', methods=['POST', 'GET'])
def suggest_chapter(lectureid):
time = request.values['time']
text = request.values['text']
assert(time and text)
time = int(time)
submitter = None
if not ismod():
submitter = request.environ['REMOTE_ADDR']
id = query('INSERT INTO chapters (lecture_id, time, text, time_created, time_updated, created_by, submitted_by) VALUES (?, ?, ?, ?, ?, ?, ?)',
lectureid, time, text, datetime.now(), datetime.now(), session.get('user', {'dbid':None})['dbid'], submitter)
if 'ref' in request.values:
return redirect(request.values['ref'])
return 'OK', 200
import feeds
import importer
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment