コード例 #1
0
 def rating_post_save(instance, sender, created, **kwargs):
     """ Send a notification when rating a layer, map or document
     """
     notice_type_label = '%s_rated' % instance.content_object.class_name.lower()
     recipients = get_notification_recipients(notice_type_label, instance.user)
     notification.send(recipients, notice_type_label, {"instance": instance})
     send_queued_notifications.delay()
コード例 #2
0
 def notification_post_delete_resource(instance, sender, **kwargs):
     """ Send a notification when a layer, map or document is deleted
     """
     notice_type_label = '%s_deleted' % instance.class_name.lower()
     recipients = get_notification_recipients(notice_type_label)
     notification.send(recipients, notice_type_label, {'resource': instance})
     send_queued_notifications.delay()
コード例 #3
0
def favorite_post_save(instance, sender, **kwargs):
    notice_type_label = '%s_favorited' % instance.content_object.class_name.lower(
    )
    extra_content = {'instance': instance, 'sender': instance.user}
    send_notification(notice_type_label,
                      instance.content_object.owner,
                      extra_content=extra_content)
    send_queued_notifications.delay()
コード例 #4
0
 def notification_post_delete_resource(instance, sender, **kwargs):
     """ Send a notification when a layer, map or document is deleted
     """
     notice_type_label = '%s_deleted' % instance.class_name.lower()
     recipients = get_notification_recipients(notice_type_label)
     notification.send(recipients, notice_type_label,
                       {'resource': instance})
     send_queued_notifications.delay()
コード例 #5
0
def favorite_post_save(instance, sender, **kwargs):
    notice_type_label = '%s_favorited' % instance.content_object.class_name.lower()
    extra_content = {
        'instance': instance,
        'sender': instance.user
    }
    send_notification(notice_type_label, instance.content_object.owner, extra_content=extra_content)
    send_queued_notifications.delay()
コード例 #6
0
 def comment_post_save(instance, sender, created, **kwargs):
     """ Send a notification when a comment to a layer, map or document has
     been submitted
     """
     notice_type_label = '%s_comment' % instance.content_object.class_name.lower()
     recipients = get_notification_recipients(notice_type_label, instance.author)
     notification.send(recipients, notice_type_label, {"instance": instance})
     send_queued_notifications.delay()
コード例 #7
0
def post_save_rating(instance, sender, **kwargs):
    author = instance.content_object.owner
    notice_type_label = '%s_rated' % instance.content_object.class_name.lower()
    extra_content = {
        'instance': instance,
        'sender': instance.user
    }
    send_notification(notice_type_label, author, extra_content=extra_content)
    send_queued_notifications.delay()
コード例 #8
0
def post_save_rating(instance, sender, **kwargs):
    author = instance.content_object.owner
    notice_type_label = '%s_rated' % instance.content_object.class_name.lower()
    extra_content = {
        'instance': instance,
        'sender': instance.user
    }
    send_notification(notice_type_label, author, extra_content=extra_content)
    send_queued_notifications.delay()
コード例 #9
0
 def rating_post_save(instance, sender, created, **kwargs):
     """ Send a notification when rating a layer, map or document
     """
     notice_type_label = '%s_rated' % instance.content_object.class_name.lower(
     )
     recipients = get_notification_recipients(notice_type_label,
                                              instance.user)
     notification.send(recipients, notice_type_label,
                       {"instance": instance})
     send_queued_notifications.delay()
コード例 #10
0
def send_notification(notice_type_label, user, extra_content=None):
    send = None
    try:
        send = user.noticesetting_set.get(notice_type__label=notice_type_label).send
    except:
        pass

    if send:
        notification.send([user], notice_type_label, {"extra_content": extra_content})
        send_queued_notifications.delay()
コード例 #11
0
def send_notification(notice_type_label, user, extra_content=None):
    send = None
    try:
        send = user.noticesetting_set.get(notice_type__label=notice_type_label).send
    except:
        pass

    if send:
        notification.send([user], notice_type_label, {"extra_content": extra_content})
        send_queued_notifications.delay()
コード例 #12
0
ファイル: signals.py プロジェクト: GeoDash/geodash
    def notification_post_save_resource(instance, sender, created, **kwargs):
        """ Send a notification when a layer, map or document is created or
        updated
        """
        notice_type_label = '%s_created' if created else '%s_updated'
        notice_type_label = notice_type_label % instance.class_name.lower()
        recipients = get_notification_recipients(notice_type_label)
        notification.send(recipients, notice_type_label, {'resource': instance})

        send_queued_notifications.delay()
コード例 #13
0
    def notification_post_save_resource(instance, sender, created, **kwargs):
        """ Send a notification when a layer, map or document is created or
        updated
        """
        notice_type_label = '%s_created' if created else '%s_updated'
        notice_type_label = notice_type_label % instance.class_name.lower()
        recipients = get_notification_recipients(notice_type_label)
        notification.send(recipients, notice_type_label,
                          {'resource': instance})

        send_queued_notifications.delay()
コード例 #14
0
 def comment_post_save(instance, sender, created, **kwargs):
     """ Send a notification when a comment to a layer, map or document has
     been submitted
     """
     notice_type_label = '%s_comment' % instance.content_object.class_name.lower(
     )
     recipients = get_notification_recipients(notice_type_label,
                                              instance.author)
     notification.send(recipients, notice_type_label,
                       {"instance": instance})
     send_queued_notifications.delay()
コード例 #15
0
    def notification_post_save_resource(instance, sender, created, **kwargs):
        """ Send a notification when a layer, map or document is created or
        updated
        """
        notice_type_label = '%s_created' if created else '%s_updated'
        notice_type_label = notice_type_label % instance.class_name.lower()
            
        #^^ do not send notification for layer_created and document_created, do it manually on upload
        if notice_type_label != 'layer_created' and notice_type_label != 'document_created': #^^
            recipients = get_notification_recipients(notice_type_label)
            notification.send(recipients, notice_type_label, {'resource': instance})

            send_queued_notifications.delay()
コード例 #16
0
ファイル: signals.py プロジェクト: alaw005/geonode
    def notification_post_save_resource2(instance_id, app_label, model, created, **kwargs):
        """ Send a notification when a layer, map or document is created or
        updated
        """
        # TODO: There is a potential race condition where this code gets
        # called but there is no information in the database yet.
        import time
        time.sleep(4)

        ct = ContentType.objects.get(app_label=app_label, model=model)
        instance_class = ct.model_class()
        instance = instance_class.objects.get(id=instance_id)
        notice_type_label = '%s_created' if created else '%s_updated'
        notice_type_label = notice_type_label % instance.class_name.lower()
        recipients = get_notification_recipients(notice_type_label)
        notification.send(recipients, notice_type_label, {'resource': instance})

        send_queued_notifications.delay()
コード例 #17
0
ファイル: signals.py プロジェクト: usaid-geonode/geonode
    def notification_post_save_resource2(instance_id, app_label, model,
                                         created, **kwargs):
        """ Send a notification when a layer, map or document is created or
        updated
        """
        # TODO: There is a potential race condition where this code gets
        # called but there is no information in the database yet.
        import time
        time.sleep(4)

        ct = ContentType.objects.get(app_label=app_label, model=model)
        instance_class = ct.model_class()
        instance = instance_class.objects.get(id=instance_id)
        notice_type_label = '%s_created' if created else '%s_updated'
        notice_type_label = notice_type_label % instance.class_name.lower()
        recipients = get_notification_recipients(notice_type_label)
        notification.send(recipients, notice_type_label,
                          {'resource': instance})

        send_queued_notifications.delay()
コード例 #18
0
def comment_post_save(instance, sender, **kwargs):
    from journal.models import JournalEntry
    if isinstance(instance.content_object, JournalEntry):
        author = instance.content_object.author
        notice_type_label = 'journal_comment'
        extra_content = {
            'instance': instance,
            'sender': instance.user
        }
        send_notification(notice_type_label, author, extra_content=extra_content)
        send_queued_notifications.delay()

    elif isinstance(instance.content_object, Layer) or isinstance(instance.content_object, Map):
        author = instance.content_object.owner
        notice_type_label = '%s_comment' % instance.content_object.class_name.lower()
        extra_content = {
            'instance': instance,
            'sender': instance.user
        }
        send_notification(notice_type_label, author, extra_content=extra_content)
        send_queued_notifications.delay()
コード例 #19
0
def comment_post_save(instance, sender, **kwargs):
    from journal.models import JournalEntry
    if isinstance(instance.content_object, JournalEntry):
        author = instance.content_object.author
        notice_type_label = 'journal_comment'
        extra_content = {'instance': instance, 'sender': instance.user}
        send_notification(notice_type_label,
                          author,
                          extra_content=extra_content)
        send_queued_notifications.delay()

    elif isinstance(instance.content_object, Layer) or isinstance(
            instance.content_object, Map):
        author = instance.content_object.owner
        notice_type_label = '%s_comment' % instance.content_object.class_name.lower(
        )
        extra_content = {'instance': instance, 'sender': instance.user}
        send_notification(notice_type_label,
                          author,
                          extra_content=extra_content)
        send_queued_notifications.delay()
コード例 #20
0
 def wrap(*args, **kwargs):
     ret = func(*args, **kwargs)
     if settings.PINAX_NOTIFICATIONS_QUEUE_ALL:
         send_queued_notifications.delay()
     return ret
コード例 #21
0
def post_save_message(instance, sender, **kwargs):
    send_notification('message_received',
                      instance.thread.users.first(),
                      extra_content={'instance': instance})
    send_queued_notifications.delay()
コード例 #22
0
 def wrap(*args, **kwargs):
     ret = func(*args, **kwargs)
     if settings.NOTIFICATION_QUEUE_ALL:
         send_queued_notifications.delay()
     return ret
コード例 #23
0
def post_save_message(instance, sender, **kwargs):
    send_notification('message_received', instance.thread.users.first(), extra_content={'instance': instance})
    send_queued_notifications.delay()