Commit 0a813aeb authored by Andreas Valder's avatar Andreas Valder
Browse files

added a delete function to the backend and the courses

parent cdb87141
......@@ -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:
......
......@@ -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);
}
}
};
......
{% 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 %}
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