user can have manual subscription applied if their current subscription is canceled
This commit is contained in:
parent
78df95395b
commit
a2ffc53c62
|
@ -117,7 +117,12 @@ def manual_upgrade(way: str, ids: [int], is_giveaway: bool):
|
|||
flash(f"Subscription extended to {manual_sub.end_at.humanize()}", "success")
|
||||
continue
|
||||
|
||||
if user.is_premium() and not user.in_trial():
|
||||
# user can have manual subscription applied if their current subscription is canceled
|
||||
if (
|
||||
user.is_premium()
|
||||
and not user.in_trial()
|
||||
and not user.subscription_cancelled
|
||||
):
|
||||
flash(f"User {user} is already premium", "warning")
|
||||
continue
|
||||
|
||||
|
|
|
@ -487,6 +487,28 @@ class User(db.Model, ModelMixin, UserMixin, PasswordOracle):
|
|||
|
||||
return "N/A"
|
||||
|
||||
@property
|
||||
def subscription_cancelled(self) -> bool:
|
||||
sub: Subscription = self.get_subscription()
|
||||
if sub and sub.cancelled:
|
||||
return True
|
||||
|
||||
apple_sub: AppleSubscription = AppleSubscription.get_by(user_id=self.id)
|
||||
if apple_sub and not apple_sub.is_valid():
|
||||
return True
|
||||
|
||||
manual_sub: ManualSubscription = ManualSubscription.get_by(user_id=self.id)
|
||||
if manual_sub and not manual_sub.is_active():
|
||||
return True
|
||||
|
||||
coinbase_subscription: CoinbaseSubscription = CoinbaseSubscription.get_by(
|
||||
user_id=self.id
|
||||
)
|
||||
if coinbase_subscription and not coinbase_subscription.is_active():
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@property
|
||||
def premium_end(self) -> str:
|
||||
if self.lifetime:
|
||||
|
|
Loading…
Reference in New Issue