Commit 7567957d authored by Julian Rother's avatar Julian Rother
Browse files

Made announcements editable

parent 547ab2c5
......@@ -238,7 +238,8 @@ def edit(prefix="", ignore=[]):
'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment',
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']),
'videos': ('videos_data', 'id', ['visible','deleted']),
'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted'])
'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted']),
'announcements': ('announcements', 'id', ['text', 'internal', 'level', 'visible', 'deleted'])
}
query('BEGIN')
if request.is_json:
......@@ -248,6 +249,7 @@ def edit(prefix="", ignore=[]):
for key, val in changes:
if key in ignore:
continue
print('edit:', key, val)
key = prefix+key
table, id, column = key.split('.', 2)
assert table in tabs
......@@ -416,5 +418,14 @@ def suggest_chapter(lectureid):
return redirect(request.values['ref'])
return 'OK', 200
@app.route('/newpsa', methods=['POST', 'GET'])
@mod_required
def new_announcement():
id = query('INSERT INTO announcements (text, internal, time_created, time_updated, created_by) VALUES ("Neue Ankündigung", "", ?, ?, ?)',
datetime.now(), datetime.now(), session.get('user', {'dbid':None})['dbid'])
if 'ref' in request.values:
return redirect(request.values['ref'])
return id, 200
import feeds
import importer
{% set page_border = page_border|default(1) %}
{% set min_announcement_level = min_announcement_level|default(1) %}
{% set announcement_levels = {0: 'info', 1: 'info', 2: 'warning', 3: 'danger'} %}
{% from 'macros.html' import valueeditor, valuecheckbox, valuedeletebtn %}
<!DOCTYPE html>
<html>
......@@ -105,7 +106,20 @@
<div class="alert alert-danger" role="alert">{{ msg }}</div>
{% endfor %}
{% for msg in get_announcements(min_announcement_level) %}
<div class="alert alert-{{announcement_levels.get(msg.level, 'info')}}" role="alert">{{ msg.text|safe }}</div>
<div class="alert alert-{{announcement_levels.get(msg.level, 'info')}}" role="alert">
{{ valueeditor(('announcements',msg.id,'text'), msg.text|safe) }}
{% if ismod() %}
<div class="pull-right">
{{ valuecheckbox(('announcements',msg.id,'visible'),msg.visible) }}
{{ valuedeletebtn(('announcements',msg.id,'deleted')) }}
</div>
<br>
{{ valueeditor(('announcements',msg.id,'internal'), msg.internal) }}
<div class="pull-right">
Level: {{ valueeditor(('announcements',msg.id,'level'), msg.level) }}
</div>
{% endif %}
</div>
{% endfor %}
{% block content %}
<h1>This is a Heading</h1>
......
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