Skip to content

Commit

Permalink
Use get_object_admin_url in Tender & Siae
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Feb 22, 2024
1 parent 5d10bba commit 79dcc49
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lemarche/templates/siaes/_detail_admin_extra_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2 class="h3">Informations Admin</h2>
</li>
{% endif %}
<li>
<a href="{% url 'admin:siaes_siae_change' siae.id %}" target="_blank" id="siae-detail-admin-btn" class="btn btn-sm btn-outline-primary btn-ico">
<a href="{{ siae.get_admin_url }}" target="_blank" id="siae-detail-admin-btn" class="btn btn-sm btn-outline-primary btn-ico">
<span>
Lien vers l'admin&nbsp;
<i class="ri-external-link-line" aria-hidden="true"></i>
Expand Down
2 changes: 1 addition & 1 deletion lemarche/templates/tenders/_detail_admin_extra_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2 class="h3">Informations Admin</h2>
</li>
{% endif %}
<li>
<a href="{% url 'admin:tenders_tender_change' tender.id %}" target="_blank" id="tender-detail-admin-btn" class="btn btn-sm btn-outline-primary btn-ico">
<a href="{{ siae.get_admin_url }}" target="_blank" id="tender-detail-admin-btn" class="btn btn-sm btn-outline-primary btn-ico">
<span>
Lien vers l'admin&nbsp;
<i class="ri-external-link-line" aria-hidden="true"></i>
Expand Down
4 changes: 4 additions & 0 deletions lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lemarche/utils/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
6 changes: 3 additions & 3 deletions lemarche/www/tenders/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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",
{
Expand Down Expand Up @@ -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",
{
Expand Down

0 comments on commit 79dcc49

Please sign in to comment.