website/conservancy/supporters/admin.py

74 lines
1.9 KiB
Python
Raw Normal View History

from django.contrib import admin
from .models import Supporter, SustainerOrder, SustainerPayment
@admin.register(Supporter)
class SupporterAdmin(admin.ModelAdmin):
list_display = ('display_name', 'display_until_date')
class SustainerPaymentInline(admin.TabularInline):
model = SustainerPayment
fields = [
'paid_time',
'amount',
'stripe_payment_intent_ref',
'stripe_invoice_ref',
]
can_delete = False
readonly_fields = [
'paid_time',
'amount',
'stripe_payment_intent_ref',
'stripe_invoice_ref',
]
def has_add_permission(self, request, obj=None):
return False
def has_change_permission(self, request, obj=None):
return False
@admin.register(SustainerOrder)
class SustainerOrderAdmin(admin.ModelAdmin):
fields = [
'created_time',
'paid_time',
'payment_method',
'stripe_customer_ref',
'stripe_subscription_ref',
'recurring',
'name',
'email',
'amount',
'acknowledge_publicly',
'add_to_mailing_list',
'tshirt_size',
'street',
'city',
'state',
'zip_code',
'country',
]
inlines = [SustainerPaymentInline]
readonly_fields = ['created_time', 'paid_time', 'payment_method', 'stripe_customer_ref', 'stripe_subscription_ref', 'recurring']
list_display = ['created_time', 'name', 'email', 'amount', 'recurring', 'paid_time']
list_filter = ['paid_time']
@admin.register(SustainerPayment)
class SustainerPaymentAdmin(admin.ModelAdmin):
fields = [
'order',
'paid_time',
'amount',
'stripe_invoice_ref',
'stripe_payment_intent_ref',
]
readonly_fields = ['order', 'paid_time', 'amount', 'stripe_invoice_ref', 'stripe_payment_intent_ref']
list_display = ['order', 'paid_time', 'amount']
list_filter = ['paid_time']