Skip to content

Commit

Permalink
admin tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Oct 30, 2024
1 parent a08563b commit 4cf7619
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/hct_mis_api/apps/household/admin/individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
IndividualRoleInHousehold,
XlsxUpdateFile,
)
from hct_mis_api.apps.payment.models import DeliveryMechanismData
from hct_mis_api.apps.utils.admin import (
BusinessAreaForIndividualCollectionListFilter,
HOPEModelAdminBase,
Expand All @@ -50,6 +51,18 @@
logger = logging.getLogger(__name__)


class IndividualDeliveryMechanismDataInline(admin.TabularInline):
model = DeliveryMechanismData
extra = 0
fields = ("delivery_mechanism_choice", "delivery_mechanism", "data", "is_valid")
readonly_fields = ("delivery_mechanism_choice", "delivery_mechanism", "data", "is_valid")
show_change_link = True
can_delete = False

def has_add_permission(self, request: HttpRequest, obj: Optional[Individual] = None) -> bool:
return False


@admin.register(Individual)
class IndividualAdmin(
SoftDeletableAdminMixin,
Expand Down Expand Up @@ -151,6 +164,7 @@ class IndividualAdmin(
("Others", {"classes": ("collapse",), "fields": ("__others__",)}),
]
actions = ["count_queryset", "revalidate_phone_number_sync", "revalidate_phone_number_async"]
inlines = [IndividualDeliveryMechanismDataInline]

def get_queryset(self, request: HttpRequest) -> QuerySet:
return (
Expand Down

0 comments on commit 4cf7619

Please sign in to comment.