From 0a179bf35056639fbc68374738e308210b7e07d7 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sun, 15 Feb 2026 12:46:50 +0330 Subject: [PATCH] admin --- apps/wallet/admin.py | 2 +- apps/wallet/models.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/wallet/admin.py b/apps/wallet/admin.py index ceb7884..3bf3dfe 100755 --- a/apps/wallet/admin.py +++ b/apps/wallet/admin.py @@ -7,7 +7,7 @@ class TransactionAdmin(admin.ModelAdmin): list_filter = ['state'] class AccountAdmin(admin.ModelAdmin): - list_display = ['uuid', 'owner_uuid', 'wallet', 'owner_type', 'balance',] + list_display = ['uuid', 'owner_uuid', 'wallet', 'owner_type', 'balance', 'get_name'] search_fields = ['uuid', 'owner_uuid'] list_filter = ['wallet__label', 'owner_type'] diff --git a/apps/wallet/models.py b/apps/wallet/models.py index f92ebc3..708cf60 100755 --- a/apps/wallet/models.py +++ b/apps/wallet/models.py @@ -54,6 +54,11 @@ class Account(BaseModel): return owner + def get_name(self): + if self.owner_type == TypeChoices.APPLICATION: + owner: Application = Application.objects.get(pk=self.owner_uuid) + return owner.name + class WalletQuerySet(models.QuerySet): pass @@ -66,6 +71,9 @@ class Wallet(BaseModel): objects = WalletQuerySet.as_manager() + def __str__(self): + return self.label + # TODO: move DRF functionalities to view or serializers # class TransactionManager(models.Manager):