This commit is contained in:
Son Nguyen Kim 2021-08-21 15:55:22 +02:00
parent bae9a6f431
commit 513f5cd4fb
2 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ def coupon_route():
return redirect(url_for("dashboard.index")) return redirect(url_for("dashboard.index"))
# handle case user already has an active subscription via another channel (Paddle, Apple, etc) # handle case user already has an active subscription via another channel (Paddle, Apple, etc)
if current_user._lifetime_or_active_subscription(): if current_user.lifetime_or_active_subscription():
manual_sub: ManualSubscription = ManualSubscription.get_by( manual_sub: ManualSubscription = ManualSubscription.get_by(
user_id=current_user.id user_id=current_user.id
) )

View File

@ -386,7 +386,7 @@ class User(db.Model, ModelMixin, UserMixin, PasswordOracle):
return user return user
def _lifetime_or_active_subscription(self) -> bool: def lifetime_or_active_subscription(self) -> bool:
"""True if user has lifetime licence or active subscription""" """True if user has lifetime licence or active subscription"""
if self.lifetime: if self.lifetime:
return True return True
@ -435,7 +435,7 @@ class User(db.Model, ModelMixin, UserMixin, PasswordOracle):
def in_trial(self): def in_trial(self):
"""return True if user does not have lifetime licence or an active subscription AND is in trial period""" """return True if user does not have lifetime licence or an active subscription AND is in trial period"""
if self._lifetime_or_active_subscription(): if self.lifetime_or_active_subscription():
return False return False
if self.trial_end and arrow.now() < self.trial_end: if self.trial_end and arrow.now() < self.trial_end:
@ -444,7 +444,7 @@ class User(db.Model, ModelMixin, UserMixin, PasswordOracle):
return False return False
def should_show_upgrade_button(self): def should_show_upgrade_button(self):
if self._lifetime_or_active_subscription(): if self.lifetime_or_active_subscription():
# user who has canceled can also re-subscribe # user who has canceled can also re-subscribe
sub: Subscription = self.get_subscription() sub: Subscription = self.get_subscription()
if sub and sub.cancelled: if sub and sub.cancelled:
@ -490,7 +490,7 @@ class User(db.Model, ModelMixin, UserMixin, PasswordOracle):
- in trial period or - in trial period or
- active subscription - active subscription
""" """
if self._lifetime_or_active_subscription(): if self.lifetime_or_active_subscription():
return True return True
if self.trial_end and arrow.now() < self.trial_end: if self.trial_end and arrow.now() < self.trial_end:
@ -582,7 +582,7 @@ class User(db.Model, ModelMixin, UserMixin, PasswordOracle):
Whether user can create a new alias. User can't create a new alias if Whether user can create a new alias. User can't create a new alias if
- has more than 15 aliases in the free plan, *even in the free trial* - has more than 15 aliases in the free plan, *even in the free trial*
""" """
if self._lifetime_or_active_subscription(): if self.lifetime_or_active_subscription():
return True return True
else: else:
return Alias.filter_by(user_id=self.id).count() < MAX_NB_EMAIL_FREE_PLAN return Alias.filter_by(user_id=self.id).count() < MAX_NB_EMAIL_FREE_PLAN