def warn_subscriptions_still_active(based_on_date=None): ending_date = based_on_date or datetime.date.today() subscriptions_still_active = Subscription.visible_objects.filter( date_end__lte=ending_date, is_active=True, ) for subscription in subscriptions_still_active: try: # needed for sending to sentry raise SubscriptionTaskError() except SubscriptionTaskError: log_accounting_error(f"{subscription} is still active.")
def warn_subscriptions_not_active(based_on_date=None): based_on_date = based_on_date or datetime.date.today() subscriptions_not_active = Subscription.visible_objects.filter( Q(date_end=None) | Q(date_end__gt=based_on_date), date_start__lte=based_on_date, is_active=False, ) for subscription in subscriptions_not_active: try: # needed for sending to sentry raise SubscriptionTaskError() except SubscriptionTaskError: log_accounting_error(f"{subscription} is not active.")