- {% if tender.author.id == APPROCH_USER_ID %}
+ {% if tender.is_partner_approch %}
Ce projet d'achat a été publié sur la plateforme APProch.
@@ -53,11 +53,7 @@
diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py
index ec9b64e09..17c13311b 100644
--- a/lemarche/tenders/admin.py
+++ b/lemarche/tenders/admin.py
@@ -186,8 +186,10 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin):
readonly_fields = [field for field in Tender.READONLY_FIELDS] + [
# slug
# status
- "author_kind_detail",
"question_count_with_link",
+ "author_kind_detail",
+ "is_partner_approch",
+ "partner_approch_id",
"siae_count_annotated_with_link",
"siae_email_send_count_annotated_with_link",
"siae_email_link_click_count_annotated_with_link",
@@ -293,6 +295,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin):
),
},
),
+ ("Partenaire APProch", {"fields": ("is_partner_approch", "partner_approch_id")}),
(
"Structures",
{
@@ -427,6 +430,12 @@ def is_validated_or_sent(self, tender: Tender):
is_validated_or_sent.boolean = True
is_validated_or_sent.short_description = "Validé / Envoyé"
+ def question_count_with_link(self, tender):
+ url = reverse("admin:tenders_tenderquestion_changelist") + f"?tender__in={tender.id}"
+ return format_html(f'
{tender.questions.count()}')
+
+ question_count_with_link.short_description = TenderQuestion._meta.verbose_name_plural
+
def author_with_link(self, tender):
url = reverse("admin:users_user_change", args=[tender.author_id])
return format_html(f'
{tender.author}')
@@ -440,11 +449,11 @@ def author_kind_detail(self, tender):
author_kind_detail.short_description = "Type du client"
author_kind_detail.admin_order_field = "author__kind"
- def question_count_with_link(self, tender):
- url = reverse("admin:tenders_tenderquestion_changelist") + f"?tender__in={tender.id}"
- return format_html(f'
{tender.questions.count()}')
+ def is_partner_approch(self, tender: Tender):
+ return tender.is_partner_approch
- question_count_with_link.short_description = TenderQuestion._meta.verbose_name_plural
+ is_partner_approch.boolean = True
+ is_partner_approch.short_description = "Partenaire APProch ?"
def siae_count_annotated_with_link(self, tender):
url = reverse("admin:siaes_siae_changelist") + f"?tenders__in={tender.id}&tendersiae__source__in="
diff --git a/lemarche/tenders/migrations/0070_tender_partner_approch_id.py b/lemarche/tenders/migrations/0070_tender_partner_approch_id.py
new file mode 100644
index 000000000..ebeabd12f
--- /dev/null
+++ b/lemarche/tenders/migrations/0070_tender_partner_approch_id.py
@@ -0,0 +1,17 @@
+# Generated by Django 4.2.9 on 2024-01-29 07:39
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("tenders", "0069_tendersiae_detail_not_interested_feedback"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="tender",
+ name="partner_approch_id",
+ field=models.IntegerField(blank=True, null=True, verbose_name="Partenaire APProch : ID"),
+ ),
+ ]
diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py
index d67388543..d7ce7c379 100644
--- a/lemarche/tenders/models.py
+++ b/lemarche/tenders/models.py
@@ -492,6 +492,8 @@ class Tender(models.Model):
help_text=ADMIN_FIELD_HELP_TEXT,
default=5,
)
+ # partner data
+ partner_approch_id = models.IntegerField("Partenaire APProch : ID", blank=True, null=True)
# stats
siae_count = models.IntegerField(
"Nombre de structures concernées", help_text=RECALCULATED_FIELD_HELP_TEXT, default=0
@@ -671,7 +673,9 @@ def questions_list(self):
@cached_property
def external_link_title(self) -> str:
- if self.kind == tender_constants.KIND_TENDER:
+ if self.is_partner_approch:
+ return "Ça m'intéresse"
+ elif self.kind == tender_constants.KIND_TENDER:
return "Voir l'appel d'offres"
return "Lien partagé"
@@ -805,6 +809,10 @@ def is_sent(self) -> bool:
def is_validated_or_sent(self) -> bool:
return self.is_validated or self.is_sent
+ @property
+ def is_partner_approch(self) -> bool:
+ return self.author_id == settings.PARTNER_APPROCH_USER_ID
+
def set_validated(self):
self.validated_at = timezone.now()
self.status = tender_constants.STATUS_VALIDATED
diff --git a/lemarche/utils/settings_context_processors.py b/lemarche/utils/settings_context_processors.py
index e2852258d..b08872163 100644
--- a/lemarche/utils/settings_context_processors.py
+++ b/lemarche/utils/settings_context_processors.py
@@ -21,7 +21,6 @@ def expose_settings(request):
"CONTACT_EMAIL": settings.CONTACT_EMAIL,
"TEAM_CONTACT_EMAIL": settings.TEAM_CONTACT_EMAIL,
"GIP_CONTACT_EMAIL": settings.GIP_CONTACT_EMAIL,
- "APPROCH_USER_ID": settings.APPROCH_USER_ID,
# forms & docs
"FACILITATOR_SLIDE": settings.FACILITATOR_SLIDE,
"FACILITATOR_LIST": settings.FACILITATOR_LIST,