From ff0533654e12d54808949c9006d13ae8e14ae0f6 Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Sun, 24 Dec 2017 03:11:15 +0100 Subject: [PATCH] Added notifications for chapter submission (closes #340) --- chapters.py | 4 ++++ templates/mails/chapter_submitted.body | 6 ++++++ templates/mails/chapter_submitted.subject | 1 + 3 files changed, 11 insertions(+) create mode 100644 templates/mails/chapter_submitted.body create mode 100644 templates/mails/chapter_submitted.subject diff --git a/chapters.py b/chapters.py index e8bd555..5c8333e 100644 --- a/chapters.py +++ b/chapters.py @@ -36,8 +36,12 @@ def suggest_chapter(lectureid): submitter = None if not ismod(): submitter = request.environ['REMOTE_ADDR'] + lecture = query('SELECT * FROM lectures WHERE id = ?', lectureid)[0] + course = query('SELECT * FROM courses WHERE id = ?', lecture['course_id'])[0] id = modify('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) + chapter = query('SELECT * FROM chapters WHERE id = ?', id)[0] + notify_mods('chapter_submitted', course['id'], course=course, lecture=lecture, chapter=chapter) if 'ref' in request.values: return redirect(request.values['ref']) return 'OK', 200 diff --git a/templates/mails/chapter_submitted.body b/templates/mails/chapter_submitted.body new file mode 100644 index 0000000..6af486f --- /dev/null +++ b/templates/mails/chapter_submitted.body @@ -0,0 +1,6 @@ +Für das Video vom {{ lecture.time|date }} wurde folgender Kapitelmarker vorgeschlagen: + +Zeit: {{ '%02d:%02d:%02d'|format( chapter.time//3600, (chapter.time//60)%60, chapter.time%60) }} +Titel: {{ chapter.text }} + +Freischalten: {{ url_for('lecture', course=course.handle, id=lecture.id, t=chapter.time, _external=True) }} diff --git a/templates/mails/chapter_submitted.subject b/templates/mails/chapter_submitted.subject new file mode 100644 index 0000000..d9e40c7 --- /dev/null +++ b/templates/mails/chapter_submitted.subject @@ -0,0 +1 @@ +Neuer Kapitelmarker in "{{ course.title }}" ({{ course.semester|semester }}) -- GitLab