mirror of
https://github.com/simple-login/app.git
synced 2025-02-24 15:53:22 +08:00
Stop paddle sub (#1216)
* admin can stop a paddle sub * show admin menu if user is admin
This commit is contained in:
parent
f340c9c9ea
commit
6c6deedf47
2 changed files with 28 additions and 0 deletions
|
@ -26,6 +26,7 @@ from app.models import (
|
|||
ProviderComplaint,
|
||||
Alias,
|
||||
Newsletter,
|
||||
PADDLE_SUBSCRIPTION_GRACE_DAYS,
|
||||
)
|
||||
from app.newsletter_utils import send_newsletter_to_user, send_newsletter_to_address
|
||||
|
||||
|
@ -199,6 +200,25 @@ class UserAdmin(SLModelView):
|
|||
|
||||
Session.commit()
|
||||
|
||||
@action(
|
||||
"stop_paddle_sub",
|
||||
"Stop user Paddle subscription",
|
||||
"This will stop the current user Paddle subscription so if user doesn't have Proton sub, they will lose all SL benefits immediately",
|
||||
)
|
||||
def stop_paddle_sub(self, ids):
|
||||
for user in User.filter(User.id.in_(ids)):
|
||||
sub: Subscription = user.get_paddle_subscription()
|
||||
if not sub:
|
||||
flash(f"No Paddle sub for {user}", "warning")
|
||||
continue
|
||||
|
||||
flash(f"{user} sub will end now, instead of {sub.next_bill_date}", "info")
|
||||
sub.next_bill_date = (
|
||||
arrow.now().shift(days=-PADDLE_SUBSCRIPTION_GRACE_DAYS).date()
|
||||
)
|
||||
|
||||
Session.commit()
|
||||
|
||||
# @action(
|
||||
# "login_as",
|
||||
# "Login as this user",
|
||||
|
|
|
@ -83,6 +83,14 @@
|
|||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if current_user.is_admin %}
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="/admin">
|
||||
<i class="fe fe-server"></i> Admin ☢️
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if ZENDESK_ENABLED %}
|
||||
|
||||
<li class="nav-item">
|
||||
|
|
Loading…
Reference in a new issue