Example #1
0
def notification_post_save_layer(instance, sender, created, **kwargs):
    if created:
        superusers = get_user_model().objects.filter(is_superuser=True)
        notification.queue(superusers, "layer_uploaded", {"from_user": instance.owner})
    else:
        # Notification if existing layer is updated
        pass
Example #2
0
def notify_comment(comment, request, **kwargs):
    logger.info('comment %s notifying' % comment.pk)
    other_commenters = User.objects.filter(
        comment_comments__content_type=comment.content_type,
        comment_comments__object_pk=comment.object_pk).distinct().exclude(
            id=comment.user_id)
    all_wishers = comment.content_object.wished_by().exclude(
        id=comment.user_id)
    other_wishers = all_wishers.exclude(id__in=other_commenters)
    domain = Site.objects.get_current().domain
    if comment.content_object.last_campaign(
    ) and comment.user in comment.content_object.last_campaign().managers.all(
    ):
        #official
        notification.queue(all_wishers, "wishlist_official_comment", {
            'comment': comment,
            'domain': domain
        }, True)
    else:
        notification.send(other_commenters,
                          "comment_on_commented", {'comment': comment},
                          True,
                          sender=comment.user)
        notification.send(other_wishers,
                          "wishlist_comment", {'comment': comment},
                          True,
                          sender=comment.user)
    from regluit.core.tasks import emit_notifications
    emit_notifications.delay()
Example #3
0
def notification_post_save_layer(instance, sender, created, **kwargs):
    if created:
        superusers = get_user_model().objects.filter(is_superuser=True)
        notification.queue(superusers, "layer_uploaded", {"from_user": instance.owner})
    else:
        # Notification if existing layer is updated
        pass
Example #4
0
def handle_credit_balance(sender, amount=0, **kwargs):
    notification.queue([sender.user], "pledge_gift_credit", {
        'user': sender.user,
        'amount': amount,
        'minus_amount': -amount
    }, True)
    from regluit.core.tasks import emit_notifications
    emit_notifications.delay()
Example #5
0
    def update_status(self, value=None, send_notice_on_change_only=True):
        """set Account.status = value unless value is None, in which case,
        we set Account.status=self.calculated_status()
        fire off associated notifications

        By default, send notices only if the status is *changing*.
        Set send_notice_on_change_only = False to
        send notice based on new_status regardless of old status.
        (Useful for initialization)
        """
        old_status = self.status

        if value is None:
            new_status = self.calculated_status()
        else:
            new_status = value

        if new_status == 'EXPIRED':
            self.deactivate()
        elif old_status != new_status:
            self.status = new_status
            self.save()

        # don't notify null users (non-users can buy-to-unglue or thank-for-ungluing)
        if self.user and (not send_notice_on_change_only or
                          (old_status != new_status)):

            logger.info("Account status change: %d %s %s", self.pk, old_status,
                        new_status)

            if new_status == 'EXPIRING':

                logger.info("EXPIRING.  send to instance.user: %s  site: %s",
                            self.user, Site.objects.get_current())

                # fire off an account_expiring notice -- might not want to do this immediately

                notification.queue([self.user], "account_expiring", {
                    'user': self.user,
                    'site': Site.objects.get_current()
                }, True)

            elif new_status == 'EXPIRED':
                logger.info("EXPIRING.  send to instance.user: %s  site: %s",
                            self.user, Site.objects.get_current())

                notification.queue([self.user], "account_expired", {
                    'user': self.user,
                    'site': Site.objects.get_current()
                }, True)

            elif new_status == 'ERROR':
                # TO DO:  what to do?
                pass

            elif new_status == 'DEACTIVATED':
                # nothing needs to happen here
                pass
def relationship_post_save(instance, sender, created, **kwargs):
    notification.queue([instance.to_user], "user_follow", {"from_user": instance.from_user})
Example #7
0
def relationship_post_save(instance, sender, created, **kwargs):
    notification.queue([instance.to_user], "user_follow",
                       {"from_user": instance.from_user})