예제 #1
0
        if is_lite(instance.user):
            usersub = UserSubscription.active_objects.get(
                user = instance.user,
                subscription__group__name = 'astrobin_lite')

            from dateutil.relativedelta import relativedelta

            usersub_created = usersub.expires - relativedelta(years=1)
            dt = instance.uploaded.date() - usersub_created
            if dt.days >= 0:
                decrease_counter(instance.user)
    except IntegrityError:
        # Possibly the user is being deleted
        pass
post_softdelete.connect(image_post_delete, sender = Image)

def imagerevision_post_save(sender, instance, created, **kwargs):
    if created and not instance.image.is_wip:
        followers = [x.user for x in ToggleProperty.objects.filter(
            property_type = "follow",
            content_type = ContentType.objects.get_for_model(User),
            object_id = instance.user.pk)]

        push_notification(followers, 'new_image_revision',
            {
                'object_url': settings.BASE_URL + instance.get_absolute_url(),
                'originator': instance.user.userprofile.get_display_name(),
            })

        add_story(instance.image.user,
예제 #2
0
            usersub = premium_get_valid_usersubscription(instance.user)
            usersub_created = usersub.expires - relativedelta(years=1)
            dt = instance.uploaded.date() - usersub_created
            if dt.days >= 0:
                decrease_counter(instance.user)
        elif is_lite_2020(instance.user) or \
                is_premium(instance.user) or \
                is_premium_2020(instance.user) or \
                is_any_ultimate(instance.user):
            decrease_counter(instance.user)
    except IntegrityError:
        # Possibly the user is being deleted
        pass


post_softdelete.connect(image_post_delete, sender=Image)


def imagerevision_post_save(sender, instance, created, **kwargs):
    if created and not instance.image.is_wip and not instance.skip_notifications:
        followers = [
            x.user for x in ToggleProperty.objects.filter(
                property_type="follow",
                content_type=ContentType.objects.get_for_model(User),
                object_id=instance.image.user.pk)
        ]

        push_notification(
            followers, 'new_image_revision', {
                'object_url': settings.BASE_URL + instance.get_absolute_url(),
                'originator':
예제 #3
0
 def setup(self):
     """Setup signals."""
     super().setup()
     post_softdelete.connect(self.handle_delete)