本文整理汇总了Python中notification.models.Notification.note方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.note方法的具体用法?Python Notification.note怎么用?Python Notification.note使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notification.models.Notification
的用法示例。
在下文中一共展示了Notification.note方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queue_notification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import note [as 别名]
def queue_notification(sender_id, recipient_id, model_name, obj_id):
"""
Adds a notification for an agree, thanks, bookmark, or follow.
Increments the notification count in the cache.
sender_id: agree.giver_id, thank.giver_id, bookmark.user_id,
or backward.source_id
recipient_id: agree.review.user_id, thank.review.user_id,
0, or backward.destination_id
model_name: string of class name
obj_id: object.pk
"""
model = get_model(MODEL_APP_NAME[model_name], model_name)
try:
pg_notification = Notification(
sender=User.objects.get(pk=sender_id),
recipient=User.objects.get(pk=recipient_id),
notification_type=model_name
)
if model_name == "agree" or model_name == "thank":
obj = model.objects.get(pk=obj_id)
pg_notification.item = obj.review.item
if model_name == "thank":
pg_notification.note = obj.note
pg_notification.save()
if not cacheAPI._get_new_notifications_count(recipient_id):
cacheAPI._reset_new_notifications_count(recipient_id)
cacheAPI._increment_new_notifications_count(recipient_id)
cacheAPI._cache_notification_for_user(pg_notification)
announce_client.emit(
recipient_id,
'notification',
data={ 'new': 1 } # Currently un-used
)
except ObjectDoesNotExist:
pass