Skip to content

Commit

Permalink
Rename tender_status to tendersiae_status (clarification)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Feb 2, 2024
1 parent b4fbeb9 commit 611238f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def with_in_user_favorite_list_stats(self, user):
def has_contact_email(self):
return self.exclude(contact_email__isnull=True).exclude(contact_email__exact="")

def filter_with_tender(self, tender, tender_status=None): # noqa C901
def filter_with_tender(self, tender, tendersiae_status=None): # noqa C901
"""
Filter Siaes with tenders:
- first we filter the Siae that are live + can be contacted
Expand All @@ -338,7 +338,7 @@ def filter_with_tender(self, tender, tender_status=None): # noqa C901
- else we filter on the perimeters
- then we filter on presta_type
- then we filter on kind
- finally we filter with the tender_status passed as a parameter
- finally we filter with the tendersiae_status passed as a parameter
Args:
tender (Tender): Tender used to make the matching
Expand Down Expand Up @@ -377,10 +377,10 @@ def filter_with_tender(self, tender, tender_status=None): # noqa C901
qs = qs.filter(kind__in=tender.siae_kind)

# tender status
if tender_status == "INTERESTED":
if tendersiae_status == "INTERESTED":
qs = qs.filter(tendersiae__tender=tender, tendersiae__detail_contact_click_date__isnull=False)
qs = qs.order_by("-tendersiae__detail_contact_click_date")
elif tender_status == "VIEWED":
elif tendersiae_status == "VIEWED":
qs = qs.filter(
Q(tendersiae__tender=tender)
& (
Expand All @@ -389,23 +389,23 @@ def filter_with_tender(self, tender, tender_status=None): # noqa C901
)
)
qs = qs.order_by("-tendersiae__email_link_click_date")
elif tender_status == "COCONTRACTED":
elif tendersiae_status == "COCONTRACTED":
qs = qs.filter(tendersiae__tender=tender, tendersiae__detail_cocontracting_click_date__isnull=False)
qs = qs.order_by("-tendersiae__detail_cocontracting_click_date")
elif tender_status == "ALL":
elif tendersiae_status == "ALL":
# why need to filter more ?
qs = qs.filter(tendersiae__tender=tender, tendersiae__email_send_date__isnull=False)
qs = qs.order_by("-tendersiae__email_send_date")

return qs.distinct()

def filter_with_tender_status(self, tender, tender_status=None):
def filter_with_tender_tendersiae_status(self, tender, tendersiae_status=None):
qs = self.prefetch_related("sectors").is_live().has_contact_email() # .filter(tendersiae__tender=tender)
# tender status
if tender_status == "INTERESTED":
if tendersiae_status == "INTERESTED":
qs = qs.filter(tendersiae__tender=tender, tendersiae__detail_contact_click_date__isnull=False)
qs = qs.order_by("-tendersiae__detail_contact_click_date")
elif tender_status == "VIEWED":
elif tendersiae_status == "VIEWED":
qs = qs.filter(
Q(tendersiae__tender=tender)
& (
Expand All @@ -414,7 +414,7 @@ def filter_with_tender_status(self, tender, tender_status=None):
)
)
qs = qs.order_by("-tendersiae__email_link_click_date")
elif tender_status == "COCONTRACTED":
elif tendersiae_status == "COCONTRACTED":
qs = qs.filter(tendersiae__tender=tender, tendersiae__detail_cocontracting_click_date__isnull=False)
qs = qs.order_by("-tendersiae__detail_cocontracting_click_date")
else: # "ALL"
Expand Down
4 changes: 2 additions & 2 deletions lemarche/templates/tenders/siae_interested_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ <h1 class="mb-3 mb-lg-5">{{ siaes.count }} prestataire{{ siaes.count|pluralize }
<i class="ri-download-line ri-lg"></i>
</button>
<div class="dropdown-menu dropdown-menu-right">
<a href="{% url 'siae:search_results_download' %}?tender={{ tender.slug }}&tender_status={{ status|default:"" }}&{{ current_search_query }}&format=xls" id="tender-siae-interested-export-xls" class="dropdown-item">
<a href="{% url 'siae:search_results_download' %}?tender={{ tender.slug }}&tendersiae_status={{ status|default:"" }}&{{ current_search_query }}&format=xls" id="tender-siae-interested-export-xls" class="dropdown-item">
Télécharger la liste (.xls)
</a>
<a href="{% url 'siae:search_results_download' %}?tender={{ tender.slug }}&tender_status={{ status|default:"" }}&{{ current_search_query }}&format=csv" id="tender-siae-interested-export-csv" class="dropdown-item">
<a href="{% url 'siae:search_results_download' %}?tender={{ tender.slug }}&tendersiae_status={{ status|default:"" }}&{{ current_search_query }}&format=csv" id="tender-siae-interested-export-csv" class="dropdown-item">
Télécharger la liste (.csv)
</a>
</div>
Expand Down
6 changes: 3 additions & 3 deletions lemarche/www/siaes/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class SiaeFilterForm(forms.Form):
tender = forms.ModelChoiceField(
queryset=Tender.objects.all(), to_field_name="slug", required=False, widget=forms.HiddenInput()
)
tender_status = forms.CharField(required=False, widget=forms.HiddenInput())
tendersiae_status = forms.CharField(required=False, widget=forms.HiddenInput())
favorite_list = forms.ModelChoiceField(
queryset=FavoriteList.objects.all(), to_field_name="slug", required=False, widget=forms.HiddenInput()
)
Expand Down Expand Up @@ -307,8 +307,8 @@ def filter_queryset(self, qs=None): # noqa C901
# a Tender author can export its Siae list
tender = self.cleaned_data.get("tender", None)
if tender:
tender_status = self.cleaned_data.get("tender_status", "ALL")
qs = qs.filter_with_tender(tender=tender, tender_status=tender_status)
tendersiae_status = self.cleaned_data.get("tendersiae_status", "ALL")
qs = qs.filter_with_tender(tender=tender, tendersiae_status=tendersiae_status)

locations = self.cleaned_data.get("locations", None)
if locations:
Expand Down
2 changes: 1 addition & 1 deletion lemarche/www/tenders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def get_queryset(self):
qs = super().get_queryset()
# first get the tender's siaes
self.tender = Tender.objects.get(slug=self.kwargs.get("slug"))
qs = qs.filter_with_tender_status(tender=self.tender, tender_status=self.status)
qs = qs.filter_with_tender_tendersiae_status(tender=self.tender, tendersiae_status=self.status)
# then filter with the form
self.filter_form = SiaeFilterForm(data=self.request.GET)
qs = self.filter_form.filter_queryset(qs)
Expand Down

0 comments on commit 611238f

Please sign in to comment.