Add a None check before doing a DT comparison when getting subscription type

This commit is contained in:
sabaimran 2024-10-25 15:22:48 -07:00
parent 0f6f282c30
commit b257fa1884

View file

@ -301,7 +301,7 @@ def subscription_to_state(subscription: Subscription) -> str:
return SubscriptionState.INVALID.value return SubscriptionState.INVALID.value
elif subscription.type == Subscription.Type.TRIAL: elif subscription.type == Subscription.Type.TRIAL:
# Check if the trial has expired # Check if the trial has expired
if datetime.now(tz=timezone.utc) > subscription.renewal_date: if subscription.renewal_date and datetime.now(tz=timezone.utc) > subscription.renewal_date:
return SubscriptionState.EXPIRED.value return SubscriptionState.EXPIRED.value
return SubscriptionState.TRIAL.value return SubscriptionState.TRIAL.value
elif subscription.is_recurring and subscription.renewal_date > datetime.now(tz=timezone.utc): elif subscription.is_recurring and subscription.renewal_date > datetime.now(tz=timezone.utc):