Skip to content
Snippets Groups Projects
Commit 4c247d43 authored by Julian Rother's avatar Julian Rother
Browse files

Added notification page

parent 9350bfa5
No related branches found
No related tags found
No related merge requests found
......@@ -206,7 +206,11 @@ CREATE TABLE IF NOT EXISTS `users` (
`last_login` datetime DEFAULT NULL,
`calendar_key` varchar(40) NOT NULL,
`rfc6238` varchar(20) NOT NULL,
`mail_notifications` INTEGER NOT NULL DEFAULT '1'
`mail_notifications` INTEGER NOT NULL DEFAULT '1',
`time_updated` datetime,
`notify_chapter_submitted` INTEGER NOT NULL DEFAULT '1',
`notify_new_video` INTEGER NOT NULL DEFAULT '1',
`notify_edit` INTEGER NOT NULL DEFAULT '0'
);
CREATE TABLE IF NOT EXISTS `videos_data` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
......
......@@ -101,7 +101,17 @@ editable_tables = {
'idcolumn': 'id',
'editable_fields': {
'deleted': {'type': 'boolean'}},
'creationtime_fields': ['time_created', 'time_updated'] }
'creationtime_fields': ['time_created', 'time_updated'] },
'users': {
'table': 'users',
'idcolumn': 'id',
'editable_fields': {
'mail_notifications': {'type': 'boolean'},
'notify_chapter_submitted': {'type': 'boolean'},
'notify_new_video': {'type': 'boolean'},
'notify_edit': {'type': 'boolean'}
},
'creationtime_fields': [] }
}
#parses the path to a dict, containing the table, id, field and field type
......
......@@ -34,7 +34,7 @@ def notify_users(msgtype, uids, **kwargs):
continue
if not user[0]['fsacc'] or not user[0]['mail_notifications']:
continue
if msgtype in user[0] and not user[0][msgtype]:
if 'notify_'+msgtype in user[0] and not user[0]['notify_'+msgtype]:
continue
if user[0]['realname']:
recipients.append('%s <%s@%s>'%(user[0]['realname'], user[0]['fsacc'],
......@@ -58,8 +58,6 @@ def notify_mods(msgtype, course_id, **kwargs):
users = query('SELECT * FROM responsible WHERE course_id = ?', course_id)
uids = []
for user in users:
if msgtype in user and not user[msgtype]:
continue
uids.append(user['user_id'])
notify_users(msgtype, uids, **kwargs)
......@@ -69,3 +67,10 @@ def notify_admins(msgtype, **kwargs):
except:
traceback.print_exc()
@app.route('/internal/notifications')
@register_navbar('Benachrichtigungen', icon='bell')
@mod_required
def user_notifications():
user = query('SELECT * FROM users WHERE id = ?', session['user']['dbid'])[0]
return render_template('user.html', user=user)
......@@ -42,12 +42,6 @@ if config['DEBUG']:
if not config.get('SECRET_KEY', None):
config['SECRET_KEY'] = os.urandom(24)
from db import query, modify, show, searchquery
from mail import notify_mods, notify_admins
from ldap import ldapauth
from legacy import legacy_index
from scheduler import sched_func
mod_endpoints = []
def mod_required(func):
......@@ -94,6 +88,12 @@ def register_navbar(name, iconlib='bootstrap', icon=None):
return func
return wrapper
from db import query, modify, show, searchquery
from mail import notify_mods, notify_admins
from ldap import ldapauth
from legacy import legacy_index
from scheduler import sched_func
def render_endpoint(endpoint, flashtext=None, **kargs):
if flashtext:
flash(flashtext)
......
{% from 'macros.html' import moderator_checkbox %}
{% extends "base.html" %}
{% block content %}
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Benachrichtigungen</h1>
</div>
<div class="panel-body">
<p>Benachrichtigungen für <code>{{ user.fsacc }}@{{ config['MAIL_SUFFIX'] }}</code> aktivieren: {{ moderator_checkbox(['users',user.id,'mail_notifications'], user.mail_notifications) }}</p> Für Veranstaltungen, bei denen du als <b>Zuständiger</b> eingetragen bist, benachrichtigen, wenn ...
<table class="table-top-aligned table-condensed"><tbody>
<tr><td>... eine Videodatei einsortiert bzw. fertig kodiert wurde:</td><td style="vertical-align: middle;">{{ moderator_checkbox(['users',user.id,'notify_new_video'], user.notify_new_video) }}</td></tr>
<tr><td>... ein Kapitelmarker vorgeschlagen wurde:</td><td style="vertical-align: middle;">{{ moderator_checkbox(['users',user.id,'notify_chapter_submitted'], user.notify_chapter_submitted) }}</td></tr>
<tr><td>... ein anderer Benutzer Felder (z.B. Titel oder Kommentar) geändert hat:</td><td style="vertical-align: middle;">{{ moderator_checkbox(['users',user.id,'notify_edit'], user.notify_edit) }}</td></tr>
</tbody></table>
</div>
</div>
</div>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment