From 30dad2519dff8f06b5127bcc941c4f807993a9e7 Mon Sep 17 00:00:00 2001 From: Domenico DiNicola Date: Wed, 30 Oct 2024 12:49:28 +0100 Subject: [PATCH] update libs --- .../apps/household/admin/individual.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/hct_mis_api/apps/household/admin/individual.py b/src/hct_mis_api/apps/household/admin/individual.py index 00d8d981a0..302c915e56 100644 --- a/src/hct_mis_api/apps/household/admin/individual.py +++ b/src/hct_mis_api/apps/household/admin/individual.py @@ -23,10 +23,7 @@ from hct_mis_api.apps.administration.widgets import JsonWidget from hct_mis_api.apps.core.models import BusinessArea -from hct_mis_api.apps.household.celery_tasks import ( - revalidate_phone_number_task, - update_individuals_iban_from_xlsx_task, -) +from hct_mis_api.apps.household.celery_tasks import revalidate_phone_number_task, update_individuals_iban_from_xlsx_task from hct_mis_api.apps.household.forms import UpdateIndividualsIBANFromXlsxForm from hct_mis_api.apps.household.models import ( Household, @@ -36,6 +33,7 @@ IndividualRoleInHousehold, XlsxUpdateFile, ) +from hct_mis_api.apps.payment.models import DeliveryMechanismData from hct_mis_api.apps.utils.admin import ( BusinessAreaForIndividualCollectionListFilter, HOPEModelAdminBase, @@ -50,6 +48,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, @@ -151,6 +161,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 (