membersystem/src/accounting/admin.py

37 lines
1.1 KiB
Python
Raw Normal View History

2024-07-15 00:19:37 +02:00
"""Admin for the accounting app."""
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
2024-07-15 00:19:37 +02:00
from .models import Order
from .models import Payment
2024-07-15 00:19:37 +02:00
@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
2024-07-15 00:19:37 +02:00
"""Admin for the Order model."""
2019-09-01 00:27:36 +02:00
list_display = ("who", "description", "created", "is_paid")
@admin.display(description=_("Customer"))
2024-07-15 00:19:37 +02:00
def who(self, instance: Order) -> str:
"""Return the full name of the user who made the order."""
return instance.user.get_full_name()
2019-09-01 00:27:36 +02:00
2024-07-15 00:19:37 +02:00
@admin.register(Payment)
class PaymentAdmin(admin.ModelAdmin):
2024-07-15 00:19:37 +02:00
"""Admin for the Payment model."""
2019-09-01 00:27:36 +02:00
list_display = ("who", "description", "order_id", "created")
@admin.display(description=_("Customer"))
2024-07-15 00:19:37 +02:00
def who(self, instance: Payment) -> str:
"""Return the full name of the user who made the payment."""
return instance.order.user.get_full_name()
2019-09-01 00:27:36 +02:00
@admin.display(description=_("Order ID"))
2024-07-15 00:19:37 +02:00
def order_id(self, instance: Payment) -> int:
"""Return the ID of the order."""
return instance.order.id