def queue(users, label, extra_context=None, on_site=True, sender=None):
"""
Queue the notification in NoticeQueueBatch. This allows for large amounts
of user notifications to be deferred to a seperate process running outside
the webserver.
"""
if extra_context is None:
extra_context = {}
if isinstance(users, QuerySet):
users = [row["pk"] for row in users.values("pk")]
else:
users = [user.pk for user in users]
notices = []
for user in users:
notices.append((user, label, extra_context, on_site, sender))
NoticeQueueBatch(pickled_data=pickle.dumps(notices).encode("base64")).save()
评论列表
文章目录