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

40 lines
1.2 KiB
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
from orchestra.apps.accounts.admin import AccountAdminMixin
2014-07-24 09:53:34 +00:00
from .methods import BankTransfer
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', 'source', 'display_state', 'amount'
2014-07-24 09:53:34 +00:00
)
list_filter = ('source__method', 'state')
2014-07-24 09:53:34 +00:00
bill_link = admin_link('bill')
account_link = admin_link('bill__account')
display_state = admin_colored('state', colors=STATE_COLORS)
class PaymentSourceAdmin(AccountAdminMixin, admin.ModelAdmin):
list_display = ('label', 'method', 'number', 'account_link', 'is_active')
list_filter = ('method', 'is_active')
form = BankTransfer().get_form()
# TODO select payment source method
admin.site.register(PaymentSource, PaymentSourceAdmin)
2014-07-24 09:53:34 +00:00
admin.site.register(Transaction, TransactionAdmin)