From 79dcc495cf634d91353b6edae0e019f1fa68e263 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Thu, 22 Feb 2024 14:32:44 +0100 Subject: [PATCH] Use get_object_admin_url in Tender & Siae --- lemarche/siaes/models.py | 4 ++++ lemarche/templates/siaes/_detail_admin_extra_info.html | 2 +- lemarche/templates/tenders/_detail_admin_extra_info.html | 2 +- lemarche/tenders/models.py | 4 ++++ lemarche/utils/urls.py | 2 +- lemarche/www/tenders/tasks.py | 6 +++--- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lemarche/siaes/models.py b/lemarche/siaes/models.py index f67140c1d..d6ea649a1 100644 --- a/lemarche/siaes/models.py +++ b/lemarche/siaes/models.py @@ -26,6 +26,7 @@ from lemarche.utils.constants import DEPARTMENTS_PRETTY, RECALCULATED_FIELD_HELP_TEXT, REGIONS_PRETTY from lemarche.utils.data import round_by_base from lemarche.utils.fields import ChoiceArrayField +from lemarche.utils.urls import get_object_admin_url def get_region_filter(perimeter): @@ -1230,6 +1231,9 @@ def siae_user_requests_pending_count(self): def get_absolute_url(self): return reverse("siae:detail", kwargs={"slug": self.slug}) + def get_admin_url(self): + return get_object_admin_url(self) + def set_super_badge(self): update_fields_list = ["super_badge"] siae_super_badge_current_value = self.super_badge diff --git a/lemarche/templates/siaes/_detail_admin_extra_info.html b/lemarche/templates/siaes/_detail_admin_extra_info.html index 55cb3d9f9..a72b224ba 100644 --- a/lemarche/templates/siaes/_detail_admin_extra_info.html +++ b/lemarche/templates/siaes/_detail_admin_extra_info.html @@ -24,7 +24,7 @@

Informations Admin

{% endif %}
  • - + Lien vers l'admin  diff --git a/lemarche/templates/tenders/_detail_admin_extra_info.html b/lemarche/templates/tenders/_detail_admin_extra_info.html index 151253f4f..e6fa4ebcd 100644 --- a/lemarche/templates/tenders/_detail_admin_extra_info.html +++ b/lemarche/templates/tenders/_detail_admin_extra_info.html @@ -44,7 +44,7 @@

    Informations Admin

  • {% endif %}
  • - + Lien vers l'admin  diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index 23b968be1..5c3d73d39 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -22,6 +22,7 @@ from lemarche.utils.apis import api_elasticsearch from lemarche.utils.constants import ADMIN_FIELD_HELP_TEXT, MARCHE_BENEFIT_CHOICES, RECALCULATED_FIELD_HELP_TEXT from lemarche.utils.fields import ChoiceArrayField +from lemarche.utils.urls import get_object_admin_url def get_perimeter_filter(siae): @@ -846,6 +847,9 @@ def siae_detail_not_interested_click_date_count(self): def get_absolute_url(self): return reverse("tenders:detail", kwargs={"slug": self.slug}) + def get_admin_url(self): + return get_object_admin_url(self) + def set_hubspot_id(self, hubspot_deal_id, with_save=True): self.extra_data.update({"hubspot_deal_id": hubspot_deal_id}) if with_save: diff --git a/lemarche/utils/urls.py b/lemarche/utils/urls.py index 120247ac9..776c99129 100644 --- a/lemarche/utils/urls.py +++ b/lemarche/utils/urls.py @@ -57,7 +57,7 @@ def get_share_url_object(obj: Model): return f"https://{get_domain_url()}{obj.get_absolute_url()}" -def get_admin_url_object(obj: Model): +def get_object_admin_url(obj: Model): admin_url = reverse_lazy(f"admin:{obj._meta.app_label}_{obj._meta.model_name}_change", args=[obj.id]) return f"https://{get_domain_url()}{admin_url}" diff --git a/lemarche/www/tenders/tasks.py b/lemarche/www/tenders/tasks.py index a8dce9285..06d274924 100644 --- a/lemarche/www/tenders/tasks.py +++ b/lemarche/www/tenders/tasks.py @@ -12,7 +12,7 @@ from lemarche.utils.apis import api_hubspot, api_mailjet, api_slack from lemarche.utils.data import date_to_string from lemarche.utils.emails import send_mail_async, whitelist_recipient_list -from lemarche.utils.urls import get_admin_url_object, get_domain_url, get_share_url_object +from lemarche.utils.urls import get_domain_url, get_object_admin_url, get_share_url_object logger = logging.getLogger(__name__) @@ -481,7 +481,7 @@ def send_siae_interested_email_to_author(tender: Tender): def notify_admin_tender_created(tender: Tender): email_subject = f"Marché de l'inclusion : dépôt de besoin, ajout d'un nouveau {tender.get_kind_display()}" - tender_admin_url = get_admin_url_object(tender) + tender_admin_url = get_object_admin_url(tender) email_body = render_to_string( "tenders/create_notification_email_admin_body.txt", { @@ -558,7 +558,7 @@ def send_tenders_author_feedback_or_survey(tender: Tender, kind="feedback_30d"): def notify_admin_siae_wants_cocontracting(tender: Tender, siae: Siae): email_subject = f"Marché de l'inclusion : la structure {siae.name} souhaite répondre en co-traitance" - tender_admin_url = get_admin_url_object(tender) + tender_admin_url = get_object_admin_url(tender) email_body = render_to_string( "tenders/cocontracting_notification_email_admin_body.txt", {