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.
67 lines
1.5 KiB
67 lines
1.5 KiB
from django.contrib import admin
|
|
from polymorphic.admin import (
|
|
PolymorphicParentModelAdmin,
|
|
PolymorphicChildModelAdmin,
|
|
PolymorphicChildModelFilter,
|
|
)
|
|
|
|
from .models import AuthorBalance, CoursePayment, SchoolPayment, Payment, GiftCertificate
|
|
|
|
|
|
@admin.register(AuthorBalance)
|
|
class AuthorBalanceAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
'author',
|
|
'type',
|
|
'amount',
|
|
'commission',
|
|
'status',
|
|
'payment',
|
|
)
|
|
|
|
|
|
class PaymentChildAdmin(PolymorphicChildModelAdmin):
|
|
base_model = Payment
|
|
show_in_index = True
|
|
list_display = (
|
|
'id',
|
|
'user',
|
|
'amount',
|
|
'status',
|
|
'created_at',
|
|
)
|
|
base_fieldsets = (
|
|
(None, {'fields': ('user', 'amount', 'status', 'data',)}),
|
|
)
|
|
readonly_fields = ('amount', 'data',)
|
|
|
|
|
|
@admin.register(CoursePayment)
|
|
class CoursePaymentAdmin(PaymentChildAdmin):
|
|
base_model = CoursePayment
|
|
list_display = PaymentChildAdmin.list_display + ('course',)
|
|
|
|
|
|
@admin.register(SchoolPayment)
|
|
class SchoolPaymentAdmin(PaymentChildAdmin):
|
|
base_model = SchoolPayment
|
|
list_display = PaymentChildAdmin.list_display + (
|
|
'weekdays',
|
|
'date_start',
|
|
'date_end',
|
|
)
|
|
|
|
|
|
@admin.register(Payment)
|
|
class PaymentAdmin(PolymorphicParentModelAdmin):
|
|
base_model = Payment
|
|
polymorphic_list = True
|
|
child_models = (
|
|
CoursePayment,
|
|
SchoolPayment,
|
|
)
|
|
|
|
|
|
@admin.register(GiftCertificate)
|
|
class GiftCertificateAdmin(admin.ModelAdmin):
|
|
pass
|
|
|