diff --git a/server.py b/server.py index 82f2616207f5ee17388f35e3b4db21cef354ecca..81d40c244ab1d723639f24d8a628b15ee0977c7d 100755 --- a/server.py +++ b/server.py @@ -149,11 +149,11 @@ def edit(): tabs = { 'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short', 'handle', 'organizer', 'subject', 'semester', 'downloadable', - 'internal', 'responsible']), + 'internal', 'responsible','deleted']), 'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment', - 'internal', 'speaker', 'place', 'time', 'duration', 'jumplist']), + 'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']), 'site_texts': ('site_texts', 'key', ['value']), - 'videos': ('videos_data', 'id', ['visible']) + 'videos': ('videos_data', 'id', ['visible','deleted']) } query('BEGIN') if request.is_json: @@ -171,6 +171,7 @@ def edit(): query('COMMIT') return "OK", 200 + @app.route('/auth') def auth(): # For use with nginx auth_request if 'X-Original-Uri' not in request.headers: diff --git a/static/moderator.js b/static/moderator.js index 4fb25a4b1ca61e4c1c6ff379b7675020401df916..745d1c3ee1117b1a25e26387f63f0aeb02169292 100644 --- a/static/moderator.js +++ b/static/moderator.js @@ -48,7 +48,7 @@ var moderatorinterface = { var path = $(src).data('path'); moderatorinterface.set(path,value ? 1 : 0); }, - set: function(path,value) { + set: function(path,value,reload=false) { var req = {}; req[path] = value; $.ajax({ @@ -56,8 +56,18 @@ var moderatorinterface = { url: "/edit", dataType: "text", contentType: "application/json", - data: JSON.stringify(req) + data: JSON.stringify(req), + success: function () { + if (reload) { + window.location.reload(); + } + } }) + }, + delete: function(src) { + if (confirm('Realy delete this?')) { + moderatorinterface.set($(src).data('path'),1,true); + } } }; diff --git a/templates/macros.html b/templates/macros.html index 1921aad046613b8a5e4cba1194a34a8b9cb87d67..629a8d9246031110bdd67b1cad565302bf6c96bf 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -1,5 +1,4 @@ {% macro preview(lecture) %} - <li class="list-group-item"> <a class="hidden-xs" href="{{url_for('play', id=lecture['id'])}}" title="{{ lecture['coursetitle'] }}"> <div class="row"> @@ -154,6 +153,7 @@ $('#embedcodebtn').popover( <span class="glyphicon glyphicon-play"></span> Play </a> + {{ valuedeletebtn(['lectures',lecture.id,'deleted']) }} </span> </span> </div> @@ -173,3 +173,11 @@ $('#embedcodebtn').popover( <input type="checkbox" data-path="{{path|join('.')}}" {% if value %} checked {% endif %} onchange="moderatorinterface.change(this)"/> {% endif %} {% endmacro %} + +{% macro valuedeletebtn (path) %} + {% if ismod() %} + <button data-path="{{path|join('.')}}" onclick="moderatorinterface.delete(this)"> + <span class="glyphicon glyphicon-trash"></span> + </button> + {% endif %} +{% endmacro %}