From 25f991f11e2e844c0d847dc33b6d2d675fc0b342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Odini?= Date: Tue, 30 Apr 2024 19:18:08 +0200 Subject: [PATCH] =?UTF-8?q?refactor(Structure):=20Admin=20:=20afficher=20l?= =?UTF-8?q?e=20nombre=20de=20besoins=20pas=20int=C3=A9ress=C3=A9s=20(#1174?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lemarche/siaes/admin.py | 15 +++++++++++++++ lemarche/siaes/models.py | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/lemarche/siaes/admin.py b/lemarche/siaes/admin.py index 6e5d5d84c..2018639a0 100644 --- a/lemarche/siaes/admin.py +++ b/lemarche/siaes/admin.py @@ -142,6 +142,7 @@ class SiaeAdmin(FieldsetsInlineMixin, gis_admin.OSMGeoAdmin): "tender_email_send_count_annotated_with_link", "tender_detail_display_count_annotated_with_link", "tender_detail_contact_click_count_annotated_with_link", + "tender_detail_not_interested_count_annotated_with_link", "offer_count_with_link", "label_count_with_link", "client_reference_count_with_link", @@ -186,6 +187,7 @@ class SiaeAdmin(FieldsetsInlineMixin, gis_admin.OSMGeoAdmin): "tender_email_link_click_count_annotated_with_link", "tender_detail_display_count_annotated_with_link", "tender_detail_contact_click_count_annotated_with_link", + "tender_detail_not_interested_count_annotated_with_link", "logs_display", "extra_data_display", "import_raw_object_display", @@ -306,6 +308,7 @@ class SiaeAdmin(FieldsetsInlineMixin, gis_admin.OSMGeoAdmin): "tender_email_link_click_count_annotated_with_link", "tender_detail_display_count_annotated_with_link", "tender_detail_contact_click_count_annotated_with_link", + "tender_detail_not_interested_count_annotated_with_link", ) }, ), @@ -607,6 +610,18 @@ def tender_detail_contact_click_count_annotated_with_link(self, siae): "tender_detail_contact_click_count_annotated" ) + def tender_detail_not_interested_count_annotated_with_link(self, siae): + url = ( + reverse("admin:tenders_tender_changelist") + + f"?siaes__in={siae.id}&tendersiae__detail_not_interested_click_date__isnull=False" + ) + return format_html(f'{getattr(siae, "tender_detail_not_interested_count_annotated", 0)}') + + tender_detail_not_interested_count_annotated_with_link.short_description = "Besoins pas intéressés" + tender_detail_not_interested_count_annotated_with_link.admin_order_field = ( + "tender_detail_not_interested_count_annotated" + ) + def logs_display(self, siae=None): if siae: return pretty_print_readonly_jsonfield(siae.logs) diff --git a/lemarche/siaes/models.py b/lemarche/siaes/models.py index 9102f7cf9..9001427b6 100644 --- a/lemarche/siaes/models.py +++ b/lemarche/siaes/models.py @@ -458,6 +458,13 @@ def with_tender_stats(self): output_field=IntegerField(), ) ), + tender_detail_not_interested_count_annotated=Sum( + Case( + When(tendersiae__detail_not_interested_click_date__isnull=False, then=1), + default=0, + output_field=IntegerField(), + ) + ), ) def with_brand_or_name(self, with_order_by=False):