Skip to content

Commit

Permalink
add current siae in to the context
Browse files Browse the repository at this point in the history
  • Loading branch information
madjid-asa committed Mar 4, 2024
1 parent e783e53 commit ed28fa0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lemarche/templates/tenders/_list_item_siae.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endif %}
</span>
Disponible <strong>jusqu'au : {{ tender.deadline_date|default:"" }}</strong>
{% if not tender.tendersiae_set.first.detail_display_date %}
{% if not current_siae.detail_display_date %}
<span class="float-right badge badge-sm badge-pill badge-new">Nouveau</span>
{% endif %}
{% endif %}
Expand Down
12 changes: 6 additions & 6 deletions lemarche/www/tenders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.paginator import Paginator
from django.db.models import Prefetch
from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse_lazy
Expand Down Expand Up @@ -277,6 +276,7 @@ class TenderListView(LoginRequiredMixin, ListView):
paginate_by = 10
paginator_class = Paginator
status = None
siae: Siae = None

def get_queryset(self):
"""
Expand All @@ -288,11 +288,9 @@ def get_queryset(self):
if user.kind == User.KIND_SIAE and user.siaes:
siaes = user.siaes.all()
if siaes:
# filtered prefetch to get detail_display_date on tendersiae_set related to user's siaes
tendersiae_qs = TenderSiae.objects.filter(siae__in=siaes)
qs = Tender.objects.filter_with_siaes(siaes).prefetch_related(
Prefetch("tendersiae_set", queryset=tendersiae_qs)
)
# we get the first siae by default
self.siae = siaes[0]
qs = Tender.objects.filter_with_siaes(siaes)
else:
qs = Tender.objects.by_user(user).with_siae_stats()
if self.status:
Expand Down Expand Up @@ -326,6 +324,8 @@ def get_context_data(self, **kwargs):
context["title_kind_sourcing_siae"] = TITLE_KIND_SOURCING_SIAE
context["tender_constants"] = tender_constants
context["filter_form"] = self.filter_form
if self.siae:
context["current_siae"] = self.siae
return context


Expand Down

0 comments on commit ed28fa0

Please sign in to comment.