diff options
author | rubenwardy <rw@rubenwardy.com> | 2020-07-09 04:16:45 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2020-07-09 04:16:45 +0100 |
commit | d0aecd0ee59663ac81733ff8087847106c7ba4cc (patch) | |
tree | 6a306fc1d4d85fb074241d18c1245301e51046e1 /app/blueprints/threads/__init__.py | |
parent | 307b8f8ddea30cb44ad02170b40dd3c0d1d3d6c3 (diff) | |
download | cheatdb-d0aecd0ee59663ac81733ff8087847106c7ba4cc.tar.xz |
Rename triggerNotif to addNotification, add array support
Diffstat (limited to 'app/blueprints/threads/__init__.py')
-rw-r--r-- | app/blueprints/threads/__init__.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/app/blueprints/threads/__init__.py b/app/blueprints/threads/__init__.py index c0b878c..09b5eb7 100644 --- a/app/blueprints/threads/__init__.py +++ b/app/blueprints/threads/__init__.py @@ -21,7 +21,7 @@ bp = Blueprint("threads", __name__) from flask_user import * from app.models import * -from app.utils import triggerNotif, clearNotifications +from app.utils import addNotification, clearNotifications import datetime @@ -113,10 +113,7 @@ def view(id): msg = "New comment on '{}' on package {}".format(thread.title, thread.package.title) - for user in thread.watchers: - if user != current_user: - triggerNotif(user, current_user, msg, url_for("threads.view", id=thread.id)) - + addNotification(thread.watchers, current_user, msg, url_for("threads.view", id=thread.id)) db.session.commit() return redirect(url_for("threads.view", id=id)) @@ -206,13 +203,12 @@ def new(): notif_msg = None if package is not None: notif_msg = "New thread '{}' on package {}".format(thread.title, package.title) - for maintainer in package.maintainers: - triggerNotif(maintainer, current_user, notif_msg, url_for("threads.view", id=thread.id)) + addNotification(package.maintainers, current_user, notif_msg, url_for("threads.view", id=thread.id)) else: notif_msg = "New thread '{}'".format(thread.title) - for user in User.query.filter(User.rank >= UserRank.EDITOR).all(): - triggerNotif(user, current_user, notif_msg, url_for("threads.view", id=thread.id)) + editors = User.query.filter(User.rank >= UserRank.EDITOR).all() + addNotification(editors, current_user, notif_msg, url_for("threads.view", id=thread.id)) db.session.commit() |