예제 #1
0
                    subscription__category__startswith='premium') \
            .exclude(pk=usersubscription.pk) \
            .update(active=False)

    if subscription.group.name == 'astrobin_lite':
        user = kwargs.get("user")
        profile = user.userprofile
        profile.premium_counter = 0
        profile.save(keep_deleted=True)

    if subscription.category == 'premium':
        push_notification([usersubscription.user], 'new_subscription',
                          {'BASE_URL': settings.BASE_URL})


subscribed.connect(subscription_subscribed)
paid.connect(subscription_subscribed)
signed_up.connect(subscription_subscribed)


def reset_lite_and_premium_counter(sender, **kwargs):
    subscription = kwargs.get("subscription")  # type: Subscription
    usersubscription = kwargs.get("usersubscription")  # type: UserSubscription
    user = usersubscription.user  # type: User

    if subscription.group.name in ('astrobin_lite_2020',
                                   'astrobin_premium_2020'):
        previous = UserSubscription.objects.filter(
            user__username=user.username,
            subscription__name__in=("AstroBin Premium", "AstroBin Lite"),
            expires__gte=datetime.date.today() - datetime.timedelta(days=180))
예제 #2
0
        usersubscription.extend(datetime.timedelta(days = 365.2425))
        usersubscription.save()

        # Invalidate other premium subscriptions
        UserSubscription.active_objects\
            .filter(user = usersubscription.user,
                    subscription__category__startswith = 'premium')\
            .exclude(pk = usersubscription.pk)\
            .update(active = False)

    if subscription.group.name == 'astrobin_lite':
        user = kwargs.get("user")
        profile = user.userprofile
        profile.premium_counter = 0
        profile.save()
subscribed.connect(subscription_subscribed)
paid.connect(subscription_subscribed)
signed_up.connect(subscription_subscribed)


def group_pre_save(sender, instance, **kwargs):
    try:
        group = sender.objects.get(pk = instance.pk)
    except sender.DoesNotExist:
        pass
    else:
        # Group is becoming autosubmission
        if not group.autosubmission and instance.autosubmission:
            instance.images.clear()
            images = Image.objects_including_wip.filter(user__in = instance.members.all())
            for image in images: