diff --git a/lemarche/siaes/admin.py b/lemarche/siaes/admin.py index 0d3157157..1bd4236c4 100644 --- a/lemarche/siaes/admin.py +++ b/lemarche/siaes/admin.py @@ -459,6 +459,7 @@ def lookup_allowed(self, lookup, *args, **kwargs): "tendersiae__detail_display_date__isnull", "tendersiae__detail_contact_click_date__isnull", "tendersiae__detail_cocontracting_click_date__isnull", + "tendersiae__detail_not_interested_click_date__isnull", ]: return True return super().lookup_allowed(lookup, *args, **kwargs) diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py index 8840947be..96ff41f08 100644 --- a/lemarche/tenders/admin.py +++ b/lemarche/tenders/admin.py @@ -195,6 +195,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): "siae_email_link_click_or_detail_display_count_annotated_with_link", "siae_detail_contact_click_count_annotated_with_link", "siae_detail_cocontracting_click_count_annotated_with_link", + "siae_detail_not_interested_click_count_annotated_with_link", "logs_display", "extra_data_display", "source", @@ -302,6 +303,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): "siae_email_link_click_or_detail_display_count_annotated_with_link", "siae_detail_contact_click_count_annotated_with_link", "siae_detail_cocontracting_click_count_annotated_with_link", + "siae_detail_not_interested_click_count_annotated_with_link", ) }, ), @@ -375,6 +377,7 @@ def lookup_allowed(self, lookup, *args, **kwargs): "tendersiae__detail_display_date__isnull", "tendersiae__detail_contact_click_date__isnull", "tendersiae__detail_cocontracting_click_date__isnull", + "tendersiae__detail_not_interested_click_date__isnull", ]: return True return super().lookup_allowed(lookup, *args, **kwargs) @@ -515,6 +518,20 @@ def siae_detail_cocontracting_click_count_annotated_with_link(self, tender): "siae_detail_cocontracting_click_count_annotated" ) + def siae_detail_not_interested_click_count_annotated_with_link(self, tender): + url = ( + reverse("admin:siaes_siae_changelist") + + f"?tenders__in={tender.id}&tendersiae__detail_not_interested_click_date__isnull=False" + ) + return format_html( + f'{getattr(tender, "siae_detail_not_interested_click_count_annotated", 0)}' + ) + + siae_detail_not_interested_click_count_annotated_with_link.short_description = "S. pas intéressées" + siae_detail_not_interested_click_count_annotated_with_link.admin_order_field = ( + "siae_detail_not_interested_click_count_annotated" + ) + def logs_display(self, tender=None): if tender: return pretty_print_readonly_jsonfield(tender.logs) diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index 5deefabca..2df5037c5 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -170,6 +170,13 @@ def with_siae_stats(self): output_field=IntegerField(), ) ), + siae_detail_not_interested_click_count_annotated=Sum( + Case( + When(tendersiae__detail_not_interested_click_date__isnull=False, then=1), + default=0, + output_field=IntegerField(), + ) + ), siae_detail_contact_click_since_last_seen_date_count_annotated=Sum( Case( When(