Skip to content

Commit

Permalink
New Tender.partner_approch_id field. New property is_partner_approch.…
Browse files Browse the repository at this point in the history
… Update admin
  • Loading branch information
raphodn committed Jan 29, 2024
1 parent 157934d commit 1825663
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@
"https://docs.google.com/forms/d/e/1FAIpQLScx1k-UJ-962_rSgPJGabc327gGjFUho6ypgcZHCubuwTl7Lg/viewform"
)
TALLY_NPS_FORM_ID = env.str("TALLY_NPS_FORM_ID", "")
APPROCH_USER_ID = env.int("APPROCH_USER_ID", 0)
PARTNER_APPROCH_USER_ID = env.int("PARTNER_APPROCH_USER_ID", 0)


# Misc
Expand Down
8 changes: 2 additions & 6 deletions lemarche/templates/tenders/_detail_contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2>
{% if tender.can_display_contact_external_link %}
<div class="row">
<div class="col-12">
{% if tender.author.id == APPROCH_USER_ID %}
{% if tender.is_partner_approch %}
<p>
<i class="ri-lightbulb-line ri-lg mr-1"></i>Ce projet d'achat a été publié sur la plateforme <strong>APProch</strong>.
<br />
Expand All @@ -53,11 +53,7 @@ <h2>
</p>
{% endif %}
<a href="{{ tender.external_link }}" target="_blank" class="btn btn-outline-primary float-right">
{% if tender.author.id == APPROCH_USER_ID %}
Ça m'intéresse
{% else %}
{{ tender.external_link_title|safe }}
{% endif %}
{{ tender.external_link_title|safe }}
<i class="ri-external-link-line" aria-hidden="true"></i>
</a>
</div>
Expand Down
19 changes: 14 additions & 5 deletions lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -292,6 +294,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin):
),
},
),
("Partenaire APProch", {"fields": ("is_partner_approch", "partner_approch_id")}),
(
"Structures",
{
Expand Down Expand Up @@ -424,6 +427,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'<a href="{url}">{tender.questions.count()}</a>')

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'<a href="{url}">{tender.author}</a>')
Expand All @@ -437,11 +446,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'<a href="{url}">{tender.questions.count()}</a>')
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}"
Expand Down
17 changes: 17 additions & 0 deletions lemarche/tenders/migrations/0070_tender_partner_approch_id.py
Original file line number Diff line number Diff line change
@@ -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"),
),
]
10 changes: 9 additions & 1 deletion lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,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
Expand Down Expand Up @@ -617,7 +619,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é"

Expand Down Expand Up @@ -747,6 +751,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
Expand Down
1 change: 0 additions & 1 deletion lemarche/utils/settings_context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1825663

Please sign in to comment.