signals.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:django-notifs 作者: danidee10 项目源码 文件源码
def create_notification(**kwargs):
    """Notify signal receiver."""
    # make fresh copy and retain kwargs
    params = kwargs.copy()
    del params['signal']
    del params['sender']
    with suppress(KeyError):
        del params['silent']

    silent = kwargs.get('silent', False)

    # If it's a silent notification create the notification but don't save it
    if silent:
        notification = Notification(**params)
    else:
        notification = Notification.objects.create(**params)

    # send via custom adapters
    for adapter_path in getattr(settings, 'NOTIFICATION_ADAPTERS', []):
        adapter = import_attr(adapter_path)
        adapter(**kwargs).notify()

    if getattr(settings, 'NOTIFICATIONS_WEBSOCKET', False):
        send_to_queue(notification)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号