django-orchestra-test/orchestra/apps/payments/admin.py

31 lines
829 B
Python
Raw Normal View History

2014-07-23 16:24:56 +00:00
from django.contrib import admin
2014-07-24 09:53:34 +00:00
from orchestra.admin.utils import admin_colored, admin_link
2014-07-23 16:24:56 +00:00
from .models import PaymentSource, Transaction
2014-07-24 09:53:34 +00:00
STATE_COLORS = {
Transaction.WAITTING_PROCESSING: 'darkorange',
Transaction.WAITTING_CONFIRMATION: 'orange',
Transaction.CONFIRMED: 'green',
Transaction.REJECTED: 'red',
Transaction.LOCKED: 'magenta',
Transaction.DISCARTED: 'blue',
}
class TransactionAdmin(admin.ModelAdmin):
list_display = (
'id', 'bill_link', 'account_link', 'method', 'display_state', 'amount'
)
list_filter = ('method', 'state')
bill_link = admin_link('bill')
account_link = admin_link('bill__account')
display_state = admin_colored('state', colors=STATE_COLORS)
2014-07-23 16:24:56 +00:00
admin.site.register(PaymentSource)
2014-07-24 09:53:34 +00:00
admin.site.register(Transaction, TransactionAdmin)