From c854894482fd424641e67de656b77fbc6ee75d90 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Mon, 18 Mar 2024 16:28:59 +0100 Subject: [PATCH] Tender matching: exclude Siae OPCS. refactor --- lemarche/siaes/models.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lemarche/siaes/models.py b/lemarche/siaes/models.py index 81141af99..394407f0f 100644 --- a/lemarche/siaes/models.py +++ b/lemarche/siaes/models.py @@ -181,12 +181,15 @@ def prefetch_many_to_many(self): def prefetch_many_to_one(self): return self.prefetch_related("offers", "client_references", "labels_old", "images") - def api_query_set(self): - return self.exclude(kind="OPCS") - def search_query_set(self): return self.is_live().exclude(kind="OPCS").prefetch_many_to_many() + def tender_matching_query_set(self): + return self.is_live().exclude(kind="OPCS").has_contact_email().prefetch_related("sectors") + + def api_query_set(self): + return self.exclude(kind="OPCS") + def filter_siret_startswith(self, siret): return self.filter(siret__startswith=siret) @@ -347,7 +350,7 @@ def filter_with_tender(self, tender, tendersiae_status=None): # noqa C901 Args: tender (Tender): Tender used to make the matching """ - qs = self.prefetch_related("sectors").is_live().has_contact_email() + qs = self.tender_matching_query_set() # filter by sectors if tender.sectors.count(): qs = qs.filter_sectors(tender.sectors.all())