Commit 21499da7 authored by Andreas Valder's avatar Andreas Valder
Browse files

added moderator interface basics

parent fc33576b
......@@ -228,7 +228,7 @@ def logout():
else:
return redirect(url_for('index'))
@app.route('/edit')
@app.route('/edit', methods=['GET', 'POST'])
@mod_required
def edit():
tabs = {
......@@ -238,13 +238,13 @@ def edit():
'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment',
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist',
'titlefile']),
'site_texts': ('site_texts', 'key' ['value']),
'site_texts': ('site_texts', 'key', ['value']),
'videos': ('videos_data', 'id', ['visible', 'downloadable', 'title',
'comment', 'internal'])
}
query('BEGIN TRANSACTION')
for key, val in request.get_json():
table, column, id = key.split('.', 2)
table, id, column = key.split('.', 2)
assert table in tabs
assert column in tabs[table][2]
query('UPDATE %s SET %s = ? WHERE %s = ?'%(tabs[table][0], column,
......
var moderatorinterface = {
init: function () {
$(function () {
var editable = $('.modeditable');
for (var i=0; i<editable.length; i++) {
var e = $(editable[i]);
$('.modeditablesign',e).popover(
{
title: e.data('path'),
html: true,
trigger: 'click',
container: 'body',
content: function() {
return `
<div class="row form-group">
<span class="col-xs-12">
<textarea class="form-control" rows="3">`+this.parentElement.getElementsByClassName('modeditablevalue')[0].innerHTML+`</textarea>
</span>
<span class="col-xs-12">
<input class="btn btn-default pull-right" type="submit" data-path="`+$(this.parentElement).data('path')+`" value="save" onClick="moderatorinterface.edit()">
</span>
</div>
`;
}
}
);
}
})
},
edit: function () {
var event = window.event;
var value = $(event.srcElement)[0].parentElement.previousElementSibling.children[0].value;
var path = $($(event.srcElement)[0]).data('path');
var editable = $('.modeditable');
for (var i=0; i<editable.length; i++) {
var e = $(editable[i]);
if (e.data('path') == path) {
$('.modeditablesign',e).click();
$(".modeditablevalue",e).html(value);
}
}
var req = {};
req[path] = value;
$.ajax({
method: "POST",
url: "/edit",
contentType: "application/json",
data: req
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
}
};
$( document ).ready( moderatorinterface.init() );
......@@ -21,6 +21,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="static/bootstrap/bootstrap.css" rel="stylesheet">
<script src="static/bootstrap/bootstrap.js"></script>
{%if ismod() %}<script src="static/moderator.js"></script>{% endif %}
</head>
<body>
<nav class="navbar navbar-default navbar-static-top">
......@@ -58,7 +59,7 @@
</li>
{% endfor %}
<li class="navbar-right">
{% if not session.user is defined %}
{% if not ismod() %}
<a id="loginpopover" data-container="body" data-toggle="popover" data-placement="bottom">
<span class="glyphicon glyphicon-log-in"></span>
</a>
......
{% from 'macros.html' import lecture_list_item %}
{% from 'macros.html' import valueeditor %}
{% from 'macros.html' import preview %}
{% extends "base.html" %}
{% block content %}
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">{{course.title}}</h1>
<h1 class="panel-title">{{ valueeditor(['courses',course.id,'title'], course.title)}}</h1>
</div>
<div class="row panel-body">
<div class="col-xs-12">
<table class="table-condensed">
<tbody>
<tr><td>Semester:</td><td>{{course.semester}}</td></tr>
<tr><td>Veranstalter:</td><td>{{course.organizer}}</td></tr>
<tr><td>Bemerkungen:</td><td>{{course.description|safe}}</td></tr>
<tr><td>Semester:</td><td>{{ valueeditor(['courses',course.id,'semester'], course.semester) }}</td></tr>
<tr><td>Veranstalter:</td><td>{{ valueeditor(['courses',course.id,'organizer'], course.organizer) }}</td></tr>
<tr><td>Bemerkungen:</td><td>{{ valueeditor(['courses',course.id,'description'], course.description) }}</td></tr>
</tbody>
</table>
</div>
......
......@@ -141,14 +141,20 @@ $('#embedcodebtn').popover(
<span class="dropdown">
{{ video_download_btn(videos) }}
</span>
<a href="/play?lectureid={{lecture.id}}">
<button class="btn btn-default {% if videos|length is equalto 0 %}disabled{% endif %}" type="button">
<span class="glyphicon glyphicon-play"></span>
<span>Play</span>
</button>
<a href="/play?lectureid={{lecture.id}}" class="btn btn-default {% if videos|length is equalto 0 %}disabled{% endif %}">
<span class="glyphicon glyphicon-play"></span>
Play
</a>
</span>
</span>
</div>
</li>
{% endmacro %}
{% macro valueeditor (path,value) %}
{% if ismod() %}
<span class="modeditable" data-path="{{path|join('.')}}" ><a class="modeditablesign btn btn-default" tabindex="0" style="padding: 3px; margin-right: 5px;"><span class="glyphicon glyphicon-pencil"></span></a><span class="modeditablevalue">{{ value|safe }}</span></span>
{% else %}
{{value|safe}}
{% 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