當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。