diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-05-13 17:55:28 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-05-13 18:04:07 +0100 |
commit | 4fdafefcd5b0267e3b9958f3dcc6b05a6eeb0906 (patch) | |
tree | aa9aa3b351302353e2ff8eaf943654c0da22a15d /app/views/utils.py | |
parent | f3c433de06e19ae9a6e1706b4746d46e6a33d70c (diff) | |
download | cheatdb-4fdafefcd5b0267e3b9958f3dcc6b05a6eeb0906.tar.xz |
Add notifications
Fixes #28
Diffstat (limited to 'app/views/utils.py')
-rw-r--r-- | app/views/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/views/utils.py b/app/views/utils.py index f22e874..345d5c1 100644 --- a/app/views/utils.py +++ b/app/views/utils.py @@ -91,3 +91,14 @@ def rank_required(rank): return decorated_function return decorator + +def triggerNotif(owner, causer, title, url): + if owner.rank.atLeast(UserRank.NEW_MEMBER) and owner != causer: + Notification.query.filter_by(user=owner, url=url).delete() + notif = Notification(owner, causer, title, url) + db.session.add(notif) + +def clearNotifications(url): + if current_user.is_authenticated: + Notification.query.filter_by(user=current_user, url=url).delete() + db.session.commit() |