当前位置: 首页>>代码示例>>Python>>正文


Python Notification.note方法代码示例

本文整理汇总了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
开发者ID:dennisai,项目名称:mavenize-beta,代码行数:39,代码来源:signalAPI.py


注:本文中的notification.models.Notification.note方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。