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

Added backend support for chapter marks

parent a1d4a0f7
......@@ -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():
......@@ -225,7 +226,8 @@ def edit(prefix="", ignore=[]):
'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:
......@@ -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
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