From c48327c963b64dcbc63415d890950d01be7bf479 Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Sun, 21 May 2017 00:58:43 +0200 Subject: [PATCH] added hints to some edit options, closes #105 --- edit.py | 17 ++++++++++++----- templates/base.html | 6 +++++- templates/course.html | 11 ++++++++++- templates/macros.html | 6 +++--- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/edit.py b/edit.py index cfd7d1e..556b2cc 100644 --- a/edit.py +++ b/edit.py @@ -14,19 +14,19 @@ editable_tables = { 'idcolumn': 'id', 'editable_fields': { 'visible': {'type': 'boolean'}, - 'listed': {'type': 'boolean'}, + 'listed': {'type': 'boolean', 'description': 'Soll die Veranstaltung auf der Hauptseite gelistet werden?'}, 'title': {'type': 'shortstring'}, - 'short': {'type': 'shortstring'}, + 'short': {'type': 'shortstring', 'description': 'Abkürzung für die Veranstaltung, z.B. für den Drehplan'}, 'handle': {'type': 'shortstring'}, 'organizer': {'type': 'shortstring'}, 'subject': {'type': 'shortstring'}, 'semester': {'type': 'shortstring'}, - 'downloadable': {'type': 'boolean'}, + 'downloadable': {'type': 'boolean', 'description': 'Hiermit kann der Download-Button disabled werden'}, 'internal': {'type': 'text'}, 'responsible': {'type': 'shortstring'}, 'deleted': {'type': 'boolean'}, 'description': {'type': 'text'}, - 'external': {'type': 'boolean'}}, + 'external': {'type': 'boolean', 'description': 'Soll die Veranstaltung nicht im Drehplan angezeigt werden?'}}, 'creationtime_fields': ['created_by', 'time_created', 'time_updated'] }, 'lectures': { 'table': 'lectures_data', @@ -42,7 +42,7 @@ editable_tables = { 'duration': {'type': 'duration'}, 'jumplist': {'type': ''}, 'deleted': {'type': 'boolean'}, - 'live': {'type': 'boolean'}, + 'live': {'type': 'boolean', 'description': 'Ist ein Livestream geplant?'}, 'norecording': {'type': 'boolean'}}, 'creationtime_fields': ['course_id', 'time_created', 'time_updated'] }, 'videos': { @@ -110,6 +110,13 @@ def parseeditpath(path): assert column in editable_tables[table]['editable_fields'] type = editable_tables[table]['editable_fields'][column]['type'] return {'table': table, 'id': id, 'column': column, 'type': type, 'tableinfo': editable_tables[table]} +@app.template_filter(name='getfielddescription') +def getfielddescription(path): + p = parseeditpath(path) + desc = p['tableinfo']['editable_fields'][p['column']].get('description', '') + if desc != '': + desc = '<br>'+desc + return desc @app.route('/internal/edit', methods=['GET', 'POST']) @mod_required diff --git a/templates/base.html b/templates/base.html index 76c17a9..b41321a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -202,7 +202,11 @@ {% endif %} <script> $( function () { - $('[data-toggle="tooltip"]').tooltip({ 'trigger': 'hover' }); + $('[data-toggle="tooltip"]').tooltip( + { + trigger: 'hover', + html: true + }); }); </script> </body> diff --git a/templates/course.html b/templates/course.html index ac596e7..0c85dd2 100644 --- a/templates/course.html +++ b/templates/course.html @@ -103,9 +103,18 @@ $.ajax({ method: "GET", url: "{{url_for('stats_generic', req="lecture_views", param=course.id)}}", dataType: "json", + error: function() { + var counter = $(".viewcounter"); + for (var i=0; i<counter.length; i++) { + $(counter[i]).text("0"); + } + }, success: function (traces) { var dates={}; - var t = traces[0] + var t = traces[0]; + if (!t.x) { + return; + } for (var i=0; i<t.x.length; i++) { dates[t.x[i]] = t.y[i]; } diff --git a/templates/macros.html b/templates/macros.html index 316c43a..0c87bac 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -267,7 +267,7 @@ $('#embedcodebtn').popover( {% macro moderator_editor (path,value,reload=false) %} {% if ismod() %} <span class="moderator_editor" data-path="{{path|join('.')}}" data-reload="{{ reload|int }}" > - <a class="moderator_editor_sign btn btn-default" title="{{path|join('.')}}" data-toggle="tooltip" tabindex="0" style="padding: 3px; margin-right: 5px;"> + <a class="moderator_editor_sign btn btn-default" title="{{path|join('.')}}{{ path|join('.')|getfielddescription }}" data-toggle="tooltip" tabindex="0" style="padding: 3px; margin-right: 5px;"> <span class="glyphicon glyphicon-pencil"></span> </a> <span class="moderator_editor_value">{{ value|fixnl|safe }}</span> @@ -279,13 +279,13 @@ $('#embedcodebtn').popover( {% macro moderator_checkbox (path,value) %} {% if ismod() %} - <input title="{{path|join('.')}}" data-toggle="tooltip" type="checkbox" data-path="{{path|join('.')}}" {% if value %} checked {% endif %} onchange="moderator.editor.changeboxclick(this)"/> + <input title="{{path|join('.')}}{{ path|join('.')|getfielddescription }}" data-toggle="tooltip" type="checkbox" data-path="{{path|join('.')}}" {% if value %} checked {% endif %} onchange="moderator.editor.changeboxclick(this)"/> {% endif %} {% endmacro %} {% macro moderator_delete (path) %} {% if ismod() %} - <button class="btn btn-default" style="background-color: red;" data-path="{{path|join('.')}}" onclick="moderator.editor.deletebtnclick(this)"> + <button class="btn btn-default" style="background-color: red;" data-path="{{path|join('.')}}" onclick="moderator.editor.deletebtnclick(this)" > <span class="glyphicon glyphicon-trash"></span> </button> {% endif %} -- GitLab