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


Python Notification.data方法代码示例

本文整理汇总了Python中notifications.models.Notification.data方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.data方法的具体用法?Python Notification.data怎么用?Python Notification.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在notifications.models.Notification的用法示例。


在下文中一共展示了Notification.data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: notify_handler

# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import data [as 别名]
def notify_handler(verb, **kwargs):
    """
    Handler function to create Notification instance upon action signal call.
    """

    kwargs.pop('signal', None)
    recipient = kwargs.pop('recipient')
    actor = kwargs.pop('sender')
    newnotify = Notification(
        recipient = recipient,
        actor_content_type=ContentType.objects.get_for_model(actor),
        actor_object_id=actor.pk,
        verb=unicode(verb),
        public=bool(kwargs.pop('public', True)),
        description=kwargs.pop('description', None),
        timestamp=kwargs.pop('timestamp', now())
    )

    for opt in ('target', 'action_object'):
        obj = kwargs.pop(opt, None)
        if not obj is None:
            setattr(newnotify, '%s_object_id' % opt, obj.pk)
            setattr(newnotify, '%s_content_type' % opt,
                    ContentType.objects.get_for_model(obj))
    
    if len(kwargs) and EXTRA_DATA:
        newnotify.data = kwargs

    newnotify.save()
开发者ID:Mondego,项目名称:pyreco,代码行数:31,代码来源:allPythonContent.py

示例2: notify_user

# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import data [as 别名]
def notify_user(recipient, actor, verb, **kwargs):
    """
    Handler function to create Notification instance upon action signal call.
    """

    new_notification = Notification(
        recipient = recipient,
        actor_content_type=ContentType.objects.get_for_model(actor),
        actor_object_id=actor.pk,
        verb=text_type(verb),
        public=bool(kwargs.pop('public', False)),
        description=kwargs.pop('description', None),
        timestamp=kwargs.pop('timestamp', utc_now()),
        level=kwargs.pop('level', Notification.LEVELS.info),
    )

    for opt in ('target', 'action_object'):
        obj = kwargs.pop(opt, None)
        if not obj is None:
            setattr(new_notification, '%s_object_id' % opt, obj.pk)
            setattr(new_notification, '%s_content_type' % opt,
                    ContentType.objects.get_for_model(obj))

    if len(kwargs) and EXTRA_DATA:
        new_notification.data = kwargs

    new_notification.save()

    return new_notification
开发者ID:omni360,项目名称:inspiration-edu-api,代码行数:31,代码来源:tasks.py


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