if user cancels subscription, user is still premium until the next billing_date + 1

This commit is contained in:
Son NK 2019-11-15 13:52:22 +01:00
parent e8b69014cd
commit 53df01e54b
1 changed files with 9 additions and 1 deletions

View File

@ -128,7 +128,15 @@ class User(db.Model, ModelMixin, UserMixin):
def is_premium(self):
"""user is premium if they have a active subscription"""
sub: Subscription = self.get_subscription()
return sub is not None and not sub.cancelled
if sub:
if sub.cancelled:
# user is premium until the next billing_date + 1
return sub.next_bill_date >= arrow.now().shift(days=-1).date()
# subscription active, ie not cancelled
return True
return False
def is_trial(self):
return self.trial_expiration is not None and self.trial_expiration > arrow.now()