You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
566 B

  1. from django.contrib import admin
  2. from .models import Subscription
  3. @admin.register(Subscription)
  4. class SubsAdmin(admin.ModelAdmin):
  5. list_display = ("id", "email", "customer_id",
  6. "payment_method_token", "subscription_id", "plan_id")
  7. list_filter = ("plan_id", )
  8. actions = ("cancel", )
  9. def email(self, obj):
  10. return obj.user.email if obj.user else None
  11. def cancel(self, request, qs):
  12. for sub in qs.all():
  13. sub.cancel()
  14. self.message_user(request, "%d subscriptions cancelled" % qs.count())