From 49632fbad1633effbc6237205271576ae01a9e60 Mon Sep 17 00:00:00 2001 From: Aadesh-Baral Date: Sun, 31 Jul 2022 11:17:33 +0545 Subject: [PATCH] Remove recommended projects from project progress emails Recommended projects logic needs some review so removing this on project progress emails for now --- backend/services/messaging/smtp_service.py | 4 ++-- .../messaging/templates/encourage_mapper_en.html | 12 +++++++----- .../services/messaging/test_smtp_service.py | 8 -------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/backend/services/messaging/smtp_service.py b/backend/services/messaging/smtp_service.py index 2fecc2c3f6..f09dc1e66f 100644 --- a/backend/services/messaging/smtp_service.py +++ b/backend/services/messaging/smtp_service.py @@ -87,12 +87,12 @@ def send_email_to_contributors_on_project_progress( for contributor_id in contributor_ids: contributor = UserService.get_user_by_id(contributor_id[0]) values["USERNAME"] = contributor.username - if email_type == EncouragingEmailType.PROJECT_COMPLETE.value: + if email_type == EncouragingEmailType.BEEN_SOME_TIME.value: recommended_projects = UserService.get_recommended_projects( contributor.username, "en" ).results projects = [] - for recommended_project in recommended_projects: + for recommended_project in recommended_projects[:4]: projects.append( { "org_logo": recommended_project.organisation_logo, diff --git a/backend/services/messaging/templates/encourage_mapper_en.html b/backend/services/messaging/templates/encourage_mapper_en.html index 5deeadd060..a351f67788 100644 --- a/backend/services/messaging/templates/encourage_mapper_en.html +++ b/backend/services/messaging/templates/encourage_mapper_en.html @@ -13,7 +13,7 @@ "> Hi {{ values["USERNAME"] }} -

+

you recently participated in the mapping project - {{values['PROJECT_NAME']}} - on the {{values["ORG_CODE"]}} Tasking Manager. @@ -36,13 +36,13 @@ "> Hi {{ values["USERNAME"] }} -

+

you recently participated in the mapping project - {{values['PROJECT_NAME']}} - on the {{values["ORG_CODE"]}} Tasking Manager. We want to inform you the project has been completed. It is time to celebrate!
- Do you want to continue? How about exploring this list of projects we selected for you? + Do you want to continue? Find the suitable project for you here: {{values['APP_BASE_URL']}}/explore

{% elif values["EMAIL_TYPE"]==3 %} @@ -65,7 +65,7 @@

{% endif %} - {% if values["EMAIL_TYPE"] !=1 %} + {% if values["EMAIL_TYPE"] ==3 %}
@@ -142,6 +142,7 @@ font-weight: 700; margin-bottom: 16px; color: #2c3038; + overflow-y: hidden; "> {{ project.name }}

@@ -151,6 +152,7 @@ color: #68707f; height: 65px; font-weight: 500; + overflow-y: hidden; "> {{ project.description }}

@@ -241,4 +243,4 @@ {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/tests/backend/integration/services/messaging/test_smtp_service.py b/tests/backend/integration/services/messaging/test_smtp_service.py index 800630f305..bce6fe07f4 100644 --- a/tests/backend/integration/services/messaging/test_smtp_service.py +++ b/tests/backend/integration/services/messaging/test_smtp_service.py @@ -173,7 +173,6 @@ def test_send_message_sends_mail_if_sender_is_defined(self): # Act/Assert SMTPService._send_message(to_address, subject, content, content) - @patch.object(UserService, "get_recommended_projects") @patch.object(SMTPService, "_send_message") @patch.object(UserService, "get_user_by_id") @patch.object(Message, "get_all_contributors") @@ -182,7 +181,6 @@ def test_send_email_to_contributors_on_project_progress( mock_get_all_contributors, mock_get_user_by_id, mock_send_message, - mock_recommended_projects, ): # Arrange mock_get_all_contributors.return_value = [(123456,)] @@ -210,9 +208,3 @@ def test_send_email_to_contributors_on_project_progress( EncouragingEmailType.PROJECT_PROGRESS.value, 1, "test", 50 ) mock_send_message.assert_called() - - # Test Recommended projects is sent on project complete email - SMTPService.send_email_to_contributors_on_project_progress( - EncouragingEmailType.PROJECT_COMPLETE.value, 1, "test", 50 - ) - mock_recommended_projects.assert_called()