display when subscription ends in admin
This commit is contained in:
parent
26a087619c
commit
9d5c2e3f80
|
@ -50,6 +50,7 @@ class UserAdmin(SLModelView):
|
|||
def scaffold_list_columns(self):
|
||||
ret = super().scaffold_list_columns()
|
||||
ret.insert(0, "upgrade_channel")
|
||||
ret.insert(0, "premium_end")
|
||||
return ret
|
||||
|
||||
@action(
|
||||
|
|
|
@ -478,6 +478,31 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
|
||||
return "N/A"
|
||||
|
||||
@property
|
||||
def premium_end(self) -> str:
|
||||
if self.lifetime:
|
||||
return "Forever"
|
||||
|
||||
sub: Subscription = self.get_subscription()
|
||||
if sub:
|
||||
return str(sub.next_bill_date)
|
||||
|
||||
apple_sub: AppleSubscription = AppleSubscription.get_by(user_id=self.id)
|
||||
if apple_sub and apple_sub.is_valid():
|
||||
return apple_sub.expires_date.humanize()
|
||||
|
||||
manual_sub: ManualSubscription = ManualSubscription.get_by(user_id=self.id)
|
||||
if manual_sub and manual_sub.is_active():
|
||||
return manual_sub.end_at.humanize()
|
||||
|
||||
coinbase_subscription: CoinbaseSubscription = CoinbaseSubscription.get_by(
|
||||
user_id=self.id
|
||||
)
|
||||
if coinbase_subscription and coinbase_subscription.is_active():
|
||||
return coinbase_subscription.end_at.humanize()
|
||||
|
||||
return "N/A"
|
||||
|
||||
def can_create_new_alias(self) -> bool:
|
||||
if self.is_premium():
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue