diff --git a/cutprogress.py b/cutprogress.py index dc216881b9da0f692fb689b4220be2338a691d7a..a46b6c9aa182a2ad5929bd7edd6cf7043ca42f2e 100644 --- a/cutprogress.py +++ b/cutprogress.py @@ -1,9 +1,14 @@ from server import * from datetime import time -@app.route('/internal/cutprogress') -@app.route('/internal/users//cutprogress') +@register_navbar('Schnittfortschritt User', icon='spinner', iconlib='fa', userendpoint=True) +@app.route('/internal/user//cutprogress') +@mod_required +def cutprogress_user(user): + return cutprogress(user) + @register_navbar('Schnittfortschritt', icon='spinner', iconlib='fa') +@app.route('/internal/cutprogress', endpoint="cutprogress") @mod_required def cutprogress(user=None): allsemester = query('SELECT DISTINCT semester from courses ORDER BY semester DESC'); @@ -24,4 +29,4 @@ def cutprogress(user=None): course['responsible'] = [{"realname": "Niemand", "id": -1}] if not user or user in [ r['id'] for r in course['responsible'] ]: courses.append(course) - return render_template('cutprogress.html', allsemester=allsemester, semester=semester, courses=courses, maxlecturecount=maxlecturecount, user=user) + return render_template('cutprogress.html', allsemester=allsemester, semester=semester, courses=courses, maxlecturecount=maxlecturecount, user=query('SELECT * FROM users WHERE id = ?', user)[0] if user else None) diff --git a/mail.py b/mail.py index b6151302fed7ef6e0a3ddecd37e227e3852e5b26..a464002cb83424ea5d6eea94d743b2f102e519fa 100644 --- a/mail.py +++ b/mail.py @@ -67,10 +67,9 @@ def notify_admins(msgtype, **kwargs): except: traceback.print_exc() -@app.route('/internal/notifications') -@register_navbar('Benachrichtigungen', icon='bell') +@app.route('/internal/user//notifications') +@register_navbar('Benachrichtigungen', icon='bell', userendpoint=True) @mod_required -def user_notifications(): - user = query('SELECT * FROM users WHERE id = ?', session['user']['dbid'])[0] - return render_template('user.html', user=user) +def user_notifications(user): + return render_template('notifications.html', user=query('SELECT * FROM users WHERE id = ?', user)[0]) diff --git a/server.py b/server.py index 08473197df571c5a5f35e3a4a45c695723744f65..282c75ebdb970290d3e68320645d41cd71612808 100644 --- a/server.py +++ b/server.py @@ -80,10 +80,10 @@ app.jinja_env.globals['navbar'] = [] # ( see: http://getbootstrap.com/components/#glyphicons ) # or 'fa' # ( see: http://fontawesome.io/icons/ ) -def register_navbar(name, iconlib='bootstrap', icon=None): +def register_navbar(name, iconlib='bootstrap', icon=None, userendpoint=False): def wrapper(func): endpoint = func.__name__ - app.jinja_env.globals['navbar'].append((endpoint, name, iconlib, icon, not endpoint in mod_endpoints)) + app.jinja_env.globals['navbar'].append((endpoint, name, iconlib, icon, not endpoint in mod_endpoints, userendpoint)) return func return wrapper diff --git a/templates/base.html b/templates/base.html index 5f09cc7fda2622a9d98b886fac23b8025c5d8fa1..7a72d98ad3d763a1104b327d45093ad8ec9f2dc7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,7 +8,7 @@ {% block header %} - Video AG {% block title %}{% for endpoint, caption, iconlib, gly, visible in navbar if ((visible or ismod()) and (endpoint == request.endpoint)) %}- {{ caption }}{% else%}{% endfor %}{% endblock %} + Video AG {% block title %}{% for endpoint, caption, iconlib, gly, visible, userendpoint in navbar if ((visible or ismod()) and (endpoint == request.endpoint)) %}- {{ caption }}{% else%}{% endfor %}{% endblock %} @@ -56,7 +56,7 @@ Brand -