diff --git a/app/admin_model.py b/app/admin_model.py index f3af2813..a49efc23 100644 --- a/app/admin_model.py +++ b/app/admin_model.py @@ -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", diff --git a/templates/menu.html b/templates/menu.html index 8920b976..47f3c345 100644 --- a/templates/menu.html +++ b/templates/menu.html @@ -83,6 +83,14 @@ {% endif %} + {% if current_user.is_admin %} + + + {% endif %} {% if ZENDESK_ENABLED %}