Skip to content

Commit

Permalink
Remove recommended projects from project progress emails
Browse files Browse the repository at this point in the history
Recommended projects logic needs some review so removing this on project progress emails for now
  • Loading branch information
Aadesh-Baral committed Jul 31, 2022
1 parent 763a8b9 commit 49632fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions backend/services/messaging/smtp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 7 additions & 5 deletions backend/services/messaging/templates/encourage_mapper_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
">
Hi {{ values["USERNAME"] }}
</h1>
<p style="margin-bottom: 1.714rem">
<p style="margin-bottom: 1.714rem; line-height: 1.5;">
you recently participated in the mapping project -
<a style="color: #d73f3f; font-weight: 700" href="{{values['APP_BASE_URL']}}/projects/{{values['PROJECT_ID']}}">{{values['PROJECT_NAME']}}</a> - on the
<a style="color: #d73f3f; font-weight: 700" href="{{values['APP_BASE_URL']}}">{{values["ORG_CODE"]}} Tasking Manager</a>.
Expand All @@ -36,13 +36,13 @@
">
Hi {{ values["USERNAME"] }}
</h1>
<p style="margin-bottom: 1.714rem">
<p style="margin-bottom: 1.714rem; line-height: 1.5;">
you recently participated in the mapping project -
<a style="color: #d73f3f; font-weight: 700" href="{{values['APP_BASE_URL']}}/projects/{{values['PROJECT_ID']}}">{{values['PROJECT_NAME']}}</a> - on the
<a style="color: #d73f3f; font-weight: 700" href="{{values['APP_BASE_URL']}}">{{values["ORG_CODE"]}} Tasking Manager</a>.
We want to inform you the project has been completed. It is time to celebrate!
<br>
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: <a href="{{values['APP_BASE_URL']}}/explore">{{values['APP_BASE_URL']}}/explore</a>
</p>
</div>
{% elif values["EMAIL_TYPE"]==3 %}
Expand All @@ -65,7 +65,7 @@
</p>
</div>
{% endif %}
{% if values["EMAIL_TYPE"] !=1 %}
{% if values["EMAIL_TYPE"] ==3 %}
<div>
<!-- card starts here -->
<table aria-label=""> <!-- Noncompliant -->
Expand Down Expand Up @@ -142,6 +142,7 @@
font-weight: 700;
margin-bottom: 16px;
color: #2c3038;
overflow-y: hidden;
">
{{ project.name }}
</p>
Expand All @@ -151,6 +152,7 @@
color: #68707f;
height: 65px;
font-weight: 500;
overflow-y: hidden;
">
{{ project.description }}
</p>
Expand Down Expand Up @@ -241,4 +243,4 @@
</div>
{% endif %}
</div>
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,)]
Expand Down Expand Up @@ -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()

0 comments on commit 49632fb

Please sign in to comment.