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):