From d644e637bf58b4b2808ca23a819f8d19cf1b5e98 Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Mon, 12 Sep 2016 01:01:09 +0200 Subject: [PATCH] added a way to suggest chapters, #22 --- server.py | 8 +++++++- templates/lecture.html | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 718633b..99ceb60 100644 --- a/server.py +++ b/server.py @@ -386,7 +386,13 @@ def suggest_chapter(lectureid): time = request.values['time'] text = request.values['text'] assert(time and text) - time = int(time) + try: + x = datetime.strptime(time,'%H:%M:%S') + time= timedelta(hours=x.hour,minutes=x.minute,seconds=x.second).total_seconds() + time = int(time) + except ValueError: + flash('Falsches Zeitformat, "%H:%M:%S" wird erwartet. Z.B. "01:39:42" für eine Kapitel bei Stunde 1, Minute 39, Sekunde 42') + submitter = None if not ismod(): submitter = request.environ['REMOTE_ADDR'] diff --git a/templates/lecture.html b/templates/lecture.html index 8c10cea..9a2cf3e 100644 --- a/templates/lecture.html +++ b/templates/lecture.html @@ -16,6 +16,7 @@ </div> <div class="col-sm-6 col-xs-12"> <ul class="list-inline pull-right"> + <li><button class="btn btn-default" id="hintnewchapter">Kapitelmarker vorschlagen</button></li> <li>{{ video_embed_btn(lecture.id) }}</li> <li class="dropdown">{{ video_download_btn(videos) }}</li> </ul> @@ -25,8 +26,21 @@ <div class="col-xs-12" style="padding: 0px"> {{ player(lecture, videos) }} </div> + <div class="col-xs-12" style="padding-top: 10px;"> + </div> </div> </div> </div> +<script> +$(function() { + $( "#hintnewchapter" ).popover( + { + html:true, + title:'Kapitelmarkierung vorschlagen', + content:'<form method="post" action="{{url_for('suggest_chapter', ref=request.url, lectureid=lecture.id)}}"><input placeholder="00:00.000" name="time" type="text"><br><input placeholder="Kapitel" name="text" type="texz"><br><input type="submit" value="Vorschlagen"></form>' + + }) +}); +</script> {% endblock %} -- GitLab