diff --git a/lemarche/templates/tenders/admin_change_form.html b/lemarche/templates/tenders/admin_change_form.html
index 4d053a7c0..bcee5cdc0 100644
--- a/lemarche/templates/tenders/admin_change_form.html
+++ b/lemarche/templates/tenders/admin_change_form.html
@@ -36,15 +36,20 @@
{% block after_related_objects %}
{{ block.super }}
{% if original %}
+ {% if not original.validated_at %}
+
+
+
+ {% endif %}
{% if original.validated_at %}
Validé le {{ original.validated_at }}.
{% if original.first_sent_at %}
Envoyé le {{ original.first_sent_at }}.
-
+
{% endif %}
{% else %}
-
+
L'envoi des besoins 'validés' se fait toutes les 5 minutes, du Lundi au Vendredi, entre 9h et 17h
{% endif %}
diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py
index cb57b77f1..996abc7ee 100644
--- a/lemarche/tenders/admin.py
+++ b/lemarche/tenders/admin.py
@@ -412,13 +412,6 @@ def save_model(self, request, obj: Tender, form, change):
obj.author = request.user
obj.save()
- def save_related(self, request, form, formsets, change):
- super().save_related(request=request, form=form, formsets=formsets, change=change)
- tender: Tender = form.instance
- # we can add `and obj.status != obj.STATUS_DRAFT` to disable matching when is draft
- if not tender.is_validated_or_sent:
- tender.set_siae_found_list()
-
def save_formset(self, request, form, formset, change):
"""
Set Note author on create
@@ -454,6 +447,7 @@ def question_count_with_link(self, tender):
question_count_with_link.short_description = TenderQuestion._meta.verbose_name_plural
+ # TODO: les siaes trouvés par l'IA apparaissent aussi ici : /admin/siaes/siae/?tenders__in=7
def siae_count_annotated_with_link(self, tender):
url = reverse("admin:siaes_siae_changelist") + f"?tenders__in={tender.id}"
return format_html(f'{getattr(tender, "siae_count_annotated", 0)}')
@@ -564,6 +558,10 @@ def response_change(self, request, obj: Tender):
"""
Catch submit of custom admin button to Validate or Resend Tender
"""
+ if request.POST.get("_calculate_tender"):
+ obj.set_siae_found_list()
+ self.message_user(request, "Les structures concernées ont été mises à jour.")
+ return HttpResponseRedirect(".")
if request.POST.get("_validate_tender"):
obj.set_validated()
self.message_user(request, "Ce dépôt de besoin a été validé. Il sera envoyé en temps voulu :)")
diff --git a/lemarche/www/pages/views.py b/lemarche/www/pages/views.py
index bd38fe443..9c4edb61b 100644
--- a/lemarche/www/pages/views.py
+++ b/lemarche/www/pages/views.py
@@ -360,7 +360,6 @@ def csrf_failure(request, reason=""): # noqa C901
else:
setattr(tender, attribute, tender_dict.get(attribute))
tender.save()
- tender.set_siae_found_list()
# remove steps data
uuid = request.session.get("tender_steps_data_uuid", None)
diff --git a/lemarche/www/tenders/views.py b/lemarche/www/tenders/views.py
index 7b5f208cb..9f15d73b9 100644
--- a/lemarche/www/tenders/views.py
+++ b/lemarche/www/tenders/views.py
@@ -232,7 +232,6 @@ def done(self, _, form_dict, **kwargs):
tender_dict = cleaned_data | {"author": user, "source": tender_constants.SOURCE_FORM}
is_draft: bool = self.request.POST.get("is_draft", False)
self.save_instance_tender(tender_dict=tender_dict, form_dict=form_dict, is_draft=is_draft)
- self.instance.set_siae_found_list()
# remove steps data
uuid = self.request.session.get("tender_steps_data_uuid", None)