From 638532adf469262d131cc75224a5cb780fa1d141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Wed, 21 Jun 2017 21:25:41 +0300 Subject: [PATCH] Admin action for cancelling a subscription --- hc/payments/admin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hc/payments/admin.py b/hc/payments/admin.py index fbf9a00a..309339e9 100644 --- a/hc/payments/admin.py +++ b/hc/payments/admin.py @@ -9,7 +9,13 @@ class SubsAdmin(admin.ModelAdmin): "payment_method_token", "subscription_id", "plan_id") list_filter = ("plan_id", ) - + actions = ("cancel", ) def email(self, obj): return obj.user.email if obj.user else None + + def cancel(self, request, qs): + for sub in qs.all(): + sub.cancel() + + self.message_user(request, "%d subscriptions cancelled" % qs.count())