From 2bd6e02fa19cea75ca75ea3172b771517c0fdbbe Mon Sep 17 00:00:00 2001 From: Christian Cueni Date: Fri, 22 Dec 2023 19:51:54 +0100 Subject: [PATCH] Update email context --- .../shop/tests/test_datatrans_webhook.py | 24 ++++++++++++++++++- server/vbv_lernwelt/shop/views.py | 15 ++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/server/vbv_lernwelt/shop/tests/test_datatrans_webhook.py b/server/vbv_lernwelt/shop/tests/test_datatrans_webhook.py index b594d95e..5850ea11 100644 --- a/server/vbv_lernwelt/shop/tests/test_datatrans_webhook.py +++ b/server/vbv_lernwelt/shop/tests/test_datatrans_webhook.py @@ -89,6 +89,22 @@ class DatatransWebhookTestCase(APITestCase): state=CheckoutState.ONGOING, ) + checkout_info = CheckoutInformation.objects.get(transaction_id=transaction_id) + checkout_info.first_name = "Max" + checkout_info.last_name = "Mustermann" + checkout_info.street = "Musterstrasse" + checkout_info.street_number = "1" + checkout_info.postal_code = "1234" + checkout_info.city = "Musterstadt" + checkout_info.country = "Schweiz" + checkout_info.company_name = "Musterfirma" + checkout_info.company_street = "Firmastrasse" + checkout_info.company_street_number = "2" + checkout_info.company_postal_code = "5678" + checkout_info.company_city = "Firmastadt" + checkout_info.company_country = "Schweiz" + checkout_info.save() + mock_is_signature_valid.return_value = True # WHEN @@ -148,8 +164,14 @@ class DatatransWebhookTestCase(APITestCase): template=EmailTemplate.WELCOME_MAIL_VV, recipient_email=self.user.email, template_data={ - "course": "Versicherungsvermittler/-in (Deutsch)", + "course": "Versicherungsvermittler/-in VBV (Deutsch)", "target_url": "https://my.vbv-afa.ch/", + "name": "Max Mustermann", + "private_street": "Musterstrasse 1", + "private_city": "1234 Musterstadt Schweiz", + "company_name": "Musterfirma", + "company_street": "Firmastrasse 2", + "company_city": "5678 Firmastadt Schweiz", }, template_language=self.user.language, fail_silently=ANY, diff --git a/server/vbv_lernwelt/shop/views.py b/server/vbv_lernwelt/shop/views.py index 50f2169b..86752d83 100644 --- a/server/vbv_lernwelt/shop/views.py +++ b/server/vbv_lernwelt/shop/views.py @@ -197,9 +197,9 @@ def update_checkout_state(checkout_info: CheckoutInformation, state: CheckoutSta def send_vv_welcome_email(checkout_info: CheckoutInformation): course_names = { - VV_DE_PRODUCT_SKU: "Versicherungsvermittler/-in (Deutsch)", - VV_FR_PRODUCT_SKU: "Intermédiaire d’assurance (Français)", - VV_IT_PRODUCT_SKU: "Intermediario/a assicurativo/a (Italiano)", + VV_DE_PRODUCT_SKU: "Versicherungsvermittler/-in VBV (Deutsch)", + VV_FR_PRODUCT_SKU: "Intermédiaire d’assurance AFA (Français)", + VV_IT_PRODUCT_SKU: "Intermediario/a assicurativo/a AFA (Italiano)", } send_email( @@ -208,8 +208,15 @@ def send_vv_welcome_email(checkout_info: CheckoutInformation): template_data={ "course": course_names[checkout_info.product_sku], "target_url": "https://my.vbv-afa.ch/", + "name": f"{checkout_info.first_name} {checkout_info.last_name}", + "private_street": f"{checkout_info.street} {checkout_info.street_number}", + "private_city": f"{checkout_info.postal_code} {checkout_info.city} {checkout_info.country}", + "company_name": checkout_info.company_name, + "company_street": f"{checkout_info.company_street} {checkout_info.company_street_number}", + "company_city": f"{checkout_info.company_postal_code} {checkout_info.company_city} {checkout_info.company_country}", }, - template_language=checkout_info.user.language, + # template_language=checkout_info.user.language, + template_language="de", fail_silently=True, )