示例#1
0
            .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))

        if previous:
示例#2
0
                    subscription__category__startswith='premium') \
            .exclude(pk=user_subscription.pk) \
            .update(active=False)

        if Transaction.objects.filter(user=user,
                                      event='new usersubscription',
                                      timestamp__gte=DateTimeService.now() -
                                      datetime.timedelta(minutes=5)):
            push_notification([user], 'new_subscription',
                              {'BASE_URL': settings.BASE_URL})
        else:
            push_notification([user], 'new_payment',
                              {'BASE_URL': settings.BASE_URL})


signed_up.connect(subscription_signed_up)


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:
                instance.images.add(image)
示例#3
0
        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(keep_deleted=True)


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:
                instance.images.add(image)
示例#4
0
        # 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:
                instance.images.add(image)