Merge pull request #854 from Gluejar/deactivate-cards

allow admin to deactivate card accounts
pull/94/head
Eric Hellman 2020-01-10 12:58:03 -05:00 committed by GitHub
commit 69e2eb69ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,5 @@
from django.contrib.admin import ModelAdmin, site
from .models import Transaction, PaymentResponse, Receiver
from .models import Transaction, PaymentResponse, Receiver, Account
class TransactionAdmin(ModelAdmin):
list_display = ('campaign', 'user', 'amount', 'status', 'error')
@ -11,8 +11,25 @@ class PaymentResponseAdmin(ModelAdmin):
class ReceiverAdmin(ModelAdmin):
ordering = ('email',)
def deactivate(modeladmin, request, queryset):
for obj in queryset:
obj.deactivate()
class AccountAdmin(ModelAdmin):
search_fields = ('user__username', 'user__email',)
list_display = ('user', 'card_type', 'card_exp_year', 'status')
readonly_fields = ('user', 'card_type', 'card_last4', 'card_exp_month', 'card_exp_year',
'date_created', 'date_modified', 'date_deactivated', 'status')
fields = readonly_fields
actions = [deactivate]
def deactivate(self, request, queryset):
for obj in queryset:
obj.deactivate()
# payments
site.register(Transaction, TransactionAdmin)
site.register(PaymentResponse, PaymentResponseAdmin)
site.register(Receiver, ReceiverAdmin)
site.register(Account, AccountAdmin)