diff --git a/db_schema.sql b/db_schema.sql index 8d75fd14a11a651720366ddcc33f87200baf327d..30c5c5827f9d5a9d5b8c5281094d98daac3149a1 100644 --- a/db_schema.sql +++ b/db_schema.sql @@ -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, diff --git a/edit.py b/edit.py index 7e64b1ee6b597eb958e315d2fe20168d84f1117b..0943c475ee72bf22ee055477fb899bab115ba268 100644 --- a/edit.py +++ b/edit.py @@ -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 diff --git a/mail.py b/mail.py index 413390ec05ffd907f6df3b104b6c203416143427..b6151302fed7ef6e0a3ddecd37e227e3852e5b26 100644 --- a/mail.py +++ b/mail.py @@ -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) + diff --git a/server.py b/server.py index 6217c771fb2c7ada51e722cd3d11b822424fa9f7..9de5db6e92b0dc5ebe529e6efc8088471630a7a1 100644 --- a/server.py +++ b/server.py @@ -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) diff --git a/templates/user.html b/templates/user.html new file mode 100644 index 0000000000000000000000000000000000000000..fda6851fa011b58e7aa272456ef7bba5492a6277 --- /dev/null +++ b/templates/user.html @@ -0,0 +1,19 @@ +{% 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 %}