From f0836ceb10945c924777cdcdb80e38b609f9a95a Mon Sep 17 00:00:00 2001 From: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Date: Tue, 30 Jan 2024 20:12:59 +0530 Subject: [PATCH] chore: email-template changes overview (#3494) * style: template design * fix: project url and actors * fix: heading jinja * fix: typo in workspace * fix: issue title change * fix: top project, issue redirection --------- Co-authored-by: NarayanBavisetti --- .../plane/bgtasks/email_notification_task.py | 6 + .../emails/notifications/issue-updates.html | 2066 +++++++++-------- 2 files changed, 1104 insertions(+), 968 deletions(-) diff --git a/apiserver/plane/bgtasks/email_notification_task.py b/apiserver/plane/bgtasks/email_notification_task.py index cf7255585..cc9588ca6 100644 --- a/apiserver/plane/bgtasks/email_notification_task.py +++ b/apiserver/plane/bgtasks/email_notification_task.py @@ -148,10 +148,12 @@ def send_email_notification( template_data = [] total_changes = 0 comments = [] + actors_involved = [] for actor_id, changes in data.items(): actor = User.objects.get(pk=actor_id) total_changes = total_changes + len(changes) comment = changes.pop("comment", False) + actors_involved.append(actor_id) if comment: comments.append( { @@ -191,6 +193,7 @@ def send_email_notification( context = { "data": template_data, "summary": summary, + "actors_involved": len(set(actors_involved)), "issue": { "issue_identifier": f"{str(issue.project.identifier)}-{str(issue.sequence_id)}", "name": issue.name, @@ -200,6 +203,9 @@ def send_email_notification( "email": receiver.email, }, "issue_url": f"{base_api}/{str(issue.project.workspace.slug)}/projects/{str(issue.project.id)}/issues/{str(issue.id)}", + "project_url": f"{base_api}/{str(issue.project.workspace.slug)}/projects/{str(issue.project.id)}/issues/", + "workspace":str(issue.project.workspace.slug), + "project": str(issue.project.name), "user_preference": f"{base_api}/profile/preferences/email", "comments": comments, } diff --git a/apiserver/templates/emails/notifications/issue-updates.html b/apiserver/templates/emails/notifications/issue-updates.html index 4374846df..bdc6a53a3 100644 --- a/apiserver/templates/emails/notifications/issue-updates.html +++ b/apiserver/templates/emails/notifications/issue-updates.html @@ -1,978 +1,1108 @@ - - - - Updates on issue - - - -
- -
- - - - -
-
- -
-
-
- -
+ + + + Updates on issue + + + + + -
- - - - -
-

- {{ issue.issue_identifier }} updates -

-

- {{ issue.name }}: {{ issue.issue_identifier }} -

-
-
- -

- {% if data.1 %}{{ data|length }}{% endif %} {{ summary }} - - {{ data.0.actor_detail.first_name}} - {{data.0.actor_detail.last_name }} - -

- {% if comments.0 %} -

- {{ comments|length }} {% if comments|length == 1 %}comment was{% else %}comments were{% endif %} left by - - {% if comments|length == 1 %} - {{ data.0.actor_detail.first_name }} - {{ data.0.actor_detail.last_name }} - {% else %} - {{ data.0.actor_detail.first_name }} - {{ data.0.actor_detail.last_name }} and others - {% endif %} - -

- {% endif %} - {% if mentions and comments.0 and data.0 %} -

- There are 3 new updates, added 1 new comment and, you were - - @{{ data.0.actor_detail.first_name}} - {{data.0.actor_detail.last_name }} - - mentioned a comment of this issue. -

- {% endif %} - {% for update in data %} {% if update.changes.name %} - -

- The issue title has been updated from “{{update.changes.user.old_value.0}}“ to "{{update.changes.user.new_value|last}}" -

- {% endif %} - - {% if data %} -
- -
-

- Updates -

-
- -
- - - -
- {% if update.actor_detail.avatar_url %} - - {% else %} - - - - - - -
+ +
+ + + - -
+
- - {{ update.actor_detail.first_name.0 }} - -
- {% endif %} + +
-

- {{ update.actor_detail.first_name }} {{ update.actor_detail.last_name }} -

-
-

- {{ update.activity_time }} -

-
- {% if update.changes.target_date %} - - - - - - - -
- - -
-

- Due Date: -

-
-
-

- {{ update.changes.target_date.new_value.0 }} -

-
- {% endif %} {% if update.changes.duplicate %} - - - - - - - - -
- - - Duplicate: - - - {% for duplicate in update.changes.duplicate.new_value %} - - {{ duplicate }} - - {% endfor %} -
- {% endif %} - - {% if update.changes.assignees %} - - - - - {% if update.changes.assignees.new_value.0 %} - - {% endif %} {% if update.changes.assignees.new_value.1 %} - - {% endif %} {% if update.changes.assignees.old_value.0 %} - - {% endif %} {% if update.changes.assignees.old_value.1 %} - - {% endif %} - -
- - -

- Assignees: -

-
-

- {{ update.changes.assignees.new_value.0 }} -

-
-

- +{{ update.changes.assignees.new_value|length|add:"-1"}} - more -

-
-

- {{update.changes.assignees.old_value.0}} -

-
-

- +{{ update.changes.assignees.old_value|length|add:"-1"}} - more -

-
- {% endif %} {% if update.changes.labels %} - - - - - - {% if update.changes.labels.new_value.0 %} - - {% endif %} - {% if update.changes.labels.new_value.1 %} - - {% endif %} - {% if update.changes.labels.old_value.0 %} - - {% endif %} - {% if update.changes.labels.old_value.1 %} - - {% endif %} - -
- - -

- Labels: -

-
-

- {{update.changes.labels.new_value.0}} -

-
-

- +{{ update.changes.labels.new_value|length|add:"-1"}} more -

-
-

- {{update.changes.labels.old_value.0}} -

-
-

- +{{ update.changes.labels.old_value|length|add:"-1"}} more -

-
- {% endif %} - - {% if update.changes.state %} - - - - - - - - - - -
- - -

- State: -

-
- - -

- {{ update.changes.state.old_value.0 }} -

-
- - - - -

- {{update.changes.state.new_value|last }} -

-
- {% endif %} {% if update.changes.link %} - - - - - - - -
- - -

- Links: -

-
- {% for link in update.changes.link.new_value %} - - {{ link }} - - {% endfor %} - {% if update.changes.link.old_value|length > 0 %} - {% if update.changes.link.old_value.0 != "None" %} -

- 2 Links were removed -

- {% endif %} - {% endif %} -
- {% endif %} - {% if update.changes.priority %} - - - - - - - - - - -
- - -

- Priority: -

-
-

- {{ update.changes.priority.old_value.0 }} -

-
- - -

- {{ update.changes.priority.new_value|last }} -

-
- {% endif %} - {% if update.changes.blocking.new_value %} - - - - - - - - -
- - - Blocking: - - - {% for blocking in update.changes.blocking.new_value %} - - {{blocking}} - - {% endfor %} -
- {% endif %} - - - {% endif %} - - {% endfor %} {% if comments.0 %} - -
- -

- Comments -

- - {% for comment in comments %} - - - - - +
- {% if comment.actor_detail.avatar_url %} - - {% else %} - - - - -
- - {{ comment.actor_detail.first_name.0 }} - -
- {% endif %} -
- - - - - {% for actor_comment in comment.actor_comments.new_value %} - - - - {% endfor %} -
-

- {{ comment.actor_detail.first_name }} {{ comment.actor_detail.last_name }} -

-
-
-

- {{ actor_comment|safe }} -

-
-
-
- {% endfor %} -
- {% endif %} - - - - - - - - -
-
- This email was sent to - {{ receiver.email }}. - If you'd rather not receive this kind of email, - you can unsubscribe to the issue - or - manage your email preferences. - -
- - + + {% if actors_involved > 0 %} + {% if data|length > 0 and comments|length == 0 %} +

+ + {{ data.0.actor_detail.first_name}} + {{data.0.actor_detail.last_name }} + + made {{data|length}} {% if data|length > 1 %}updates{% else %}update{% endif %} to the issue. +

+ {% elif data|length == 0 and comments|length > 0 %} +

+ + {{ comments.0.actor_detail.first_name}} + {{comments.0.actor_detail.last_name }} + + added {{comments|length}} new {% if comments|length > 1 %}comments{% else %}comment{% endif %}. +

+ {% elif data|length > 0 and comments|length > 0 %} +

+ + {{ data.0.actor_detail.first_name}} + {{data.0.actor_detail.last_name }} + + made {{data|length}} {% if data|length > 1 %}updates{% else %}update{% endif %} and added {{comments|length}} new {% if comments|length > 1 %}comments{% else %}comment{% endif %} on the issue. +

+ {% endif %} + {% else %} +

+ There are {{ data|length }} new updates and {{comments|length}} new comments on the issue +

+ {% endif %} + {% for update in data %} {% if update.changes.name %} + +

+ The issue title has been updated to {{ issue.name}} +

+ {% endif %} + + {% if data %} +
+ +
+

+ Updates +

+
+ +
+ + + + + + + +
+ {% if update.actor_detail.avatar_url %} + + {% else %} + + + + +
+ + {{ update.actor_detail.first_name.0 }} + +
+ {% endif %} +
+

+ {{ update.actor_detail.first_name }} {{ update.actor_detail.last_name }} +

+
+

+ {{ update.activity_time }} +

+
+ {% if update.changes.target_date %} + + + + + + + +
+ + +
+

+ Due Date: +

+
+
+ {% if update.changes.target_date.new_value.0 %} +

+ {{ update.changes.target_date.new_value.0 }} +

+ {% else %} +

+ {{ update.changes.target_date.old_value.0 }} +

+ {% endif %} +
+ {% endif %} {% if update.changes.duplicate %} + + + + + {% if update.changes.duplicate.new_value.0 %} + + {% endif %} + {% if update.changes.duplicate.new_value.2 %} + + {% endif %} + {% if update.changes.duplicate.old_value.0 %} + + {% endif %} + {% if update.changes.duplicate.old_value.2 %} + + {% endif %} + +
+ + + Duplicate: + + + {% for duplicate in update.changes.duplicate.new_value|slice:":2" %} + + {{ duplicate }} + + {% endfor %} + + + +{{ update.changes.duplicate.new_value|length|add:"-2" }} + more + + + {% for duplicate in update.changes.duplicate.old_value|slice:":2" %} + + {{ duplicate }} + + {% endfor %} + + + +{{ update.changes.duplicate.old_value|length|add:"-2" }} + more + +
+ {% endif %} + + {% if update.changes.assignees %} + + + + + +
+ + + Assignee: + + + {% if update.changes.assignees.new_value.0 %} + + {{update.changes.assignees.new_value.0}} + + {% endif %} + {% if update.changes.assignees.new_value.1 %} + + +{{ update.changes.assignees.new_value|length|add:"-1"}} more + + {% endif %} + {% if update.changes.assignees.old_value.0 %} + + {{update.changes.assignees.old_value.0}} + + {% endif %} + {% if update.changes.assignees.old_value.1 %} + + +{{ update.changes.assignees.old_value|length|add:"-1"}} more + + {% endif %} +
+ {% endif %} {% if update.changes.labels %} + + + + + + +
+ + + Labels: + + + {% if update.changes.labels.new_value.0 %} + + {{update.changes.labels.new_value.0}} + + {% endif %} + {% if update.changes.labels.new_value.1 %} + + +{{ update.changes.labels.new_value|length|add:"-1"}} more + + {% endif %} + {% if update.changes.labels.old_value.0 %} + + {{update.changes.labels.old_value.0}} + + {% endif %} + {% if update.changes.labels.old_value.1 %} + + +{{ update.changes.labels.old_value|length|add:"-1"}} more + + {% endif %} +
+ {% endif %} + + {% if update.changes.state %} + + + + + + + + + + +
+ + +

+ State: +

+
+ + +

+ {{ update.changes.state.old_value.0 }} +

+
+ + + + +

+ {{update.changes.state.new_value|last }} +

+
+ {% endif %} {% if update.changes.link %} + + + + + + + +
+ + +

+ Links: +

+
+ {% for link in update.changes.link.new_value %} + + {{ link }} + + {% endfor %} + {% if update.changes.link.old_value|length > 0 %} + {% if update.changes.link.old_value.0 != "None" %} +

+ 2 Links were removed +

+ {% endif %} + {% endif %} +
+ {% endif %} + {% if update.changes.priority %} + + + + + + + + + +
+ + +

+ Priority: +

+
+

+ {{ update.changes.priority.old_value.0 }} +

+
+ + +

+ {{ update.changes.priority.new_value|last }} +

+
+ {% endif %} + {% if update.changes.blocking.new_value %} + + + + + {% if update.changes.blocking.new_value.0 %} + + {% endif %} + {% if update.changes.blocking.new_value.2 %} + + {% endif %} + {% if update.changes.blocking.old_value.0 %} + + {% endif %} + {% if update.changes.blocking.old_value.2 %} + + {% endif %} + +
+ + + Blocking: + + + {% for blocking in update.changes.blocking.new_value|slice:":2" %} + + {{ blocking }} + + {% endfor %} + + + +{{ update.changes.blocking.new_value|length|add:"-2" }} + more + + + {% for blocking in update.changes.blocking.old_value|slice:":2" %} + + {{ blocking }} + + {% endfor %} + + + +{{ update.changes.blocking.old_value|length|add:"-2" }} + more + +
+ {% endif %} +
+
+ {% endif %} + + {% endfor %} {% if comments.0 %} + +
+ +

+ Comments +

+ + {% for comment in comments %} + + + + + +
+ {% if comment.actor_detail.avatar_url %} + + {% else %} + + + + +
+ + {{ comment.actor_detail.first_name.0 }} + +
+ {% endif %} +
+ + + + + {% for actor_comment in comment.actor_comments.new_value %} + + + + {% endfor %} +
+

+ {{ comment.actor_detail.first_name }} {{ comment.actor_detail.last_name }} +

+
+
+

+ {{ actor_comment|safe }} +

+
+
+
+ {% endfor %} +
+ {% endif %}
-
- - - + +
+ View issue +
+
+ + + + + + +
+
+ This email was sent to + {{ receiver.email }}. + If you'd rather not receive this kind of email, + you can unsubscribe to the issue + or + manage your email preferences. + + +
+
+ + + \ No newline at end of file