Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dépôt de besoin] Dans les e-mails aux prestataires, envoyer aussi le montant #967

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,17 @@ def location_display(self) -> str:
# maintain legacy perimeters display
return self.perimeters_list_string

@cached_property
def amount_display(self) -> str:
if not self.accept_share_amount:
return "Non renseigné"
elif self.amount_exact:
return f"{self.amount_exact} €"
elif self.amount:
return self.get_amount_display()
else:
return "Non renseigné"

def questions_list(self):
return list(self.questions.values("id", "text"))

Expand Down Expand Up @@ -546,7 +557,7 @@ def cta_card_paragraph_text(self):
elif self.kind == tender_constants.KIND_QUOTE:
return "Accéder aux coordonnées du client afin de lui envoyer un devis."
elif self.kind == tender_constants.KIND_PROJECT and self.response_is_anonymous:
return "Manifestez votre intérêt au client. Sil est intéressé, le client vous recontactera via les coordonnées présentes sur votre fiche commerciale." # noqa
return "Manifestez votre intérêt au client. S'il est intéressé, le client vous recontactera via les coordonnées présentes sur votre fiche commerciale." # noqa
elif self.kind == tender_constants.KIND_PROJECT:
return "Accéder aux coordonnées du client afin de lui présenter vos services et produits."
# just in case
Expand Down
16 changes: 16 additions & 0 deletions lemarche/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ def test_status(self):
self.assertTrue(tender_validated_half.is_validated, False)
self.assertTrue(tender_validated_full.is_validated, True)

def test_amount_display(self):
tender_with_amount = TenderFactory(amount=tender_constants.AMOUNT_RANGE_0_1, accept_share_amount=True)
tender_with_amount_2 = TenderFactory(amount=tender_constants.AMOUNT_RANGE_10_15, accept_share_amount=True)
tender_with_amount_exact = TenderFactory(
amount=tender_constants.AMOUNT_RANGE_10_15, amount_exact=10000, accept_share_amount=True
)
tender_dont_share_amount = TenderFactory(
amount=tender_constants.AMOUNT_RANGE_10_15, amount_exact=10000, accept_share_amount=False
)
tender_no_amount = TenderFactory(amount=None, amount_exact=None, accept_share_amount=True)
self.assertEqual(tender_with_amount.amount_display, "0-1000 €")
self.assertEqual(tender_with_amount_2.amount_display, "10-15 K€")
self.assertEqual(tender_with_amount_exact.amount_display, "10000 €")
self.assertEqual(tender_dont_share_amount.amount_display, "Non renseigné")
self.assertEqual(tender_no_amount.amount_display, "Non renseigné")


class TenderModelSaveTest(TestCase):
def test_set_slug(self):
Expand Down
4 changes: 4 additions & 0 deletions lemarche/www/tenders/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def send_tender_email_to_siae(tender: Tender, siae: Siae, email_subject: str, em
"TENDER_KIND": tender.get_kind_display(),
"TENDER_SECTORS": tender.sectors_list_string(),
"TENDER_PERIMETERS": tender.location_display,
"TENDER_AMOUNT": tender.amount_display,
"TENDER_DEADLINE_DATE": date_to_string(tender.deadline_date),
"TENDER_URL": f"{get_share_url_object(tender)}?siae_id={siae.id}",
}
Expand Down Expand Up @@ -213,6 +214,7 @@ def send_tender_contacted_reminder_email_to_siae(
"TENDER_KIND": tendersiae.tender.get_kind_display(),
"TENDER_SECTORS": tendersiae.tender.sectors_list_string(),
"TENDER_PERIMETERS": tendersiae.tender.location_display,
"TENDER_AMOUNT": tendersiae.tender.amount_display,
"TENDER_DEADLINE_DATE": date_to_string(tendersiae.tender.deadline_date),
"TENDER_URL": f"{get_share_url_object(tendersiae.tender)}?siae_id={tendersiae.siae.id}&mtm_campaign=relance-esi-contactees", # noqa
}
Expand Down Expand Up @@ -286,6 +288,7 @@ def send_tender_interested_reminder_email_to_siae(
"TENDER_KIND": tendersiae.tender.get_kind_display(),
"TENDER_SECTORS": tendersiae.tender.sectors_list_string(),
"TENDER_PERIMETERS": tendersiae.tender.location_display,
"TENDER_AMOUNT": tendersiae.tender.amount_display,
"TENDER_DEADLINE_DATE": date_to_string(tendersiae.tender.deadline_date),
"TENDER_URL": f"{get_share_url_object(tendersiae.tender)}?siae_id={tendersiae.siae.id}&mtm_campaign=relance-esi-interessees", # noqa
}
Expand Down Expand Up @@ -329,6 +332,7 @@ def send_confirmation_published_email_to_author(tender: Tender, nb_matched_siaes
"TENDER_KIND": tender.get_kind_display(),
"TENDER_SECTORS": tender.sectors_list_string(),
"TENDER_PERIMETERS": tender.location_display,
"TENDER_AMOUNT": tender.amount_display,
"TENDER_DEADLINE_DATE": date_to_string(tender.deadline_date),
"TENDER_NB_MATCH": nb_matched_siaes,
"TENDER_URL": get_share_url_object(tender),
Expand Down