You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
498 B
Python

import logging
from .models import Subscription, ACTIVE_BACKENDS
logger = logging.getLogger(__name__)
from celery import task
@task
def check_subscriptions():
logger.debug("checking subscriptions")
subs = Subscription.objects.filter(status='active', backend_id='stripe').all()
for sub in subs:
logger.debug("checking subscription #%s on %s", sub.id, sub.backend_id)
sub.refresh_from_db()
ACTIVE_BACKENDS['stripe'].refresh_subscription(sub)
sub.save()