diff --git a/backend/config.py b/backend/config.py index d2efbc9300..c30c073268 100644 --- a/backend/config.py +++ b/backend/config.py @@ -103,7 +103,7 @@ class EnvironmentConfig: MAIL_DEBUG = True if LOG_LEVEL == "DEBUG" else False # If disabled project update emails will not be sent. - SEND_PROJECT_EMAIL_UPDATES = os.getenv("TM_SEND_PROJECT_EMAIL_UPDATES", True) + SEND_PROJECT_EMAIL_UPDATES = int(os.getenv("TM_SEND_PROJECT_EMAIL_UPDATES", True)) # Languages offered by the Tasking Manager # Please note that there must be exactly the same number of Codes as languages. diff --git a/backend/services/messaging/message_service.py b/backend/services/messaging/message_service.py index 41732bff85..966a05ba0e 100644 --- a/backend/services/messaging/message_service.py +++ b/backend/services/messaging/message_service.py @@ -102,7 +102,10 @@ def send_message_after_validation( validation_message.task_id = task_id validation_message.from_user_id = validated_by validation_message.to_user_id = mapped_by - validation_message.subject = f"{task_link} mapped by you in project {project_name} has been {status_text}" + validation_message.subject = ( + f"{task_link} mapped by you in Project " + + f"{project_name} #{project_id} has been {status_text}" + ) validation_message.message = text_template messages.append( dict(message=validation_message, user=user, project_name=project_name) @@ -241,7 +244,10 @@ def send_message_after_comment( message.task_id = task_id message.from_user_id = comment_from message.to_user_id = user.id - message.subject = f"You were mentioned in a comment in {task_link} of project {project_name}" + message.subject = ( + f"You were mentioned in a comment in {task_link} " + + f"of Project {project_name} #{project_id}" + ) message.message = comment messages.append( dict(message=message, user=user, project_name=project_name) @@ -284,7 +290,7 @@ def send_message_after_comment( message.from_user_id = comment_from message.task_id = task_id message.to_user_id = user.id - message.subject = f"{user_link} left a comment in {task_link} of project {project_name}" + message.subject = f"{user_link} left a comment in {task_link} of Project {project_name} #{project_id}" message.message = comment messages.append( dict(message=message, user=user, project_name=project_name) @@ -309,11 +315,9 @@ def send_project_transfer_message( message = Message() message.message_type = MessageType.PROJECT_ACTIVITY_NOTIFICATION.value - message.subject = ( - f"Project {project_name} was transferred to {transferred_to}" - ) + message.subject = f"Project {project_name} #{project_id} was transferred to {transferred_to}" message.message = ( - f"Project {project_name} associated with your " + f"Project {project_name} #{project_id} associated with your" + f"organisation {project.organisation.name} was transferred to {transferred_to} by {transferred_by}." ) values = { @@ -474,7 +478,7 @@ def send_message_after_chat( message.project_id = project_id message.from_user_id = chat_from message.to_user_id = user.id - message.subject = f"You were mentioned in project {link} chat" + message.subject = f"You were mentioned in Project {link} chat" message.message = chat messages.append( dict(message=message, user=user, project_name=project_name) @@ -768,7 +772,7 @@ def get_project_link( else: section = "" - return f'{project_name}' + return f'{project_name} #{project_id}' @staticmethod def get_user_profile_link(user_name: str, base_url=None) -> str: diff --git a/backend/services/messaging/templates/message_alert_en.html b/backend/services/messaging/templates/message_alert_en.html index 7565ec91e8..f617c3197c 100644 --- a/backend/services/messaging/templates/message_alert_en.html +++ b/backend/services/messaging/templates/message_alert_en.html @@ -2,19 +2,19 @@ {% block content %}
{% if values['MESSAGE_TYPE'] == 3 %} -

@{{values['FROM_USERNAME']}} mentioned you in a comment on Project {{values['PROJECT_ID']}}:

+

@{{values['FROM_USERNAME']}} mentioned you in a comment on Project {{values['PROJECT_NAME']}} #{{values['PROJECT_ID']}}:

{% endif %} {% if values['MESSAGE_TYPE'] == 4 %} -

Task validated on Project {{values['PROJECT_ID']}}:

+

Task validated on Project {{values['PROJECT_NAME']}} #{{values['PROJECT_ID']}}:

{% endif %} {% if values['MESSAGE_TYPE'] == 5 %} -

Task on Project {{values['PROJECT_ID']}} needs more mapping:

+

Task on Project {{values['PROJECT_NAME']}} #{{values['PROJECT_ID']}} needs more mapping:

{% endif %} {% if values['MESSAGE_TYPE'] == 8 %} -

@{{values['FROM_USERNAME']}} left a comment on Task {{values['TASK_ID']}} in Project {{values['PROJECT_ID']}}:

+

@{{values['FROM_USERNAME']}} left a comment on Task {{values['TASK_ID']}} in Project {{values['PROJECT_NAME']}} #{{values['PROJECT_ID']}}:

{% endif %} {% if values['MESSAGE_TYPE'] == 9 %} -

@{{values['FROM_USERNAME']}} left a comment on Project {{values['PROJECT_ID']}}:

+

@{{values['FROM_USERNAME']}} left a comment on Project {{values['PROJECT_NAME']}} #{{values['PROJECT_ID']}}:

{% endif %}

{{ values['CONTENT']|safe }} diff --git a/tests/backend/unit/services/messaging/test_messaging_service.py b/tests/backend/unit/services/messaging/test_messaging_service.py index 0dd8c13c34..aa717b033c 100644 --- a/tests/backend/unit/services/messaging/test_messaging_service.py +++ b/tests/backend/unit/services/messaging/test_messaging_service.py @@ -31,7 +31,7 @@ def test_message_service_generates_correct_chat_link(self): self.assertEqual( link, - 'TEST_PROJECT', + 'TEST_PROJECT #1', ) link = MessageService.get_project_link( 1, @@ -41,5 +41,5 @@ def test_message_service_generates_correct_chat_link(self): self.assertEqual( link, - 'TEST_PROJECT', + 'TEST_PROJECT #1', )