Skip to content

Commit a714f3b

Browse files
sudip-khanalsusilnem
authored andcommitted
fix(template): update local unit email template
1 parent fad2a4a commit a714f3b

File tree

6 files changed

+55
-19
lines changed

6 files changed

+55
-19
lines changed

local_units/serializers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ class PrivateLocalUnitSerializer(serializers.ModelSerializer):
446446
status_details = serializers.CharField(source="get_status_display", read_only=True)
447447
modified_by_details = LocalUnitMiniUserSerializer(source="modified_by", read_only=True)
448448
is_locked = serializers.BooleanField(read_only=True)
449+
update_reason_overview = serializers.CharField(read_only=True)
449450

450451
class Meta:
451452
model = LocalUnit
@@ -473,6 +474,7 @@ class Meta:
473474
"is_locked",
474475
"is_new_local_unit",
475476
"bulk_upload",
477+
"update_reason_overview",
476478
)
477479

478480
def get_location_geojson(self, unit) -> dict:

local_units/tasks.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def send_local_unit_email(local_unit_id: int, new: bool = True):
4545

4646
for user in users:
4747
# NOTE: Adding the validator email to the context
48+
if not user.email:
49+
logger.warning(f"Email address not found for validator: {user.get_full_name()}.")
50+
return None
4851
email_context["validator_email"] = user.email
4952
email_context["full_name"] = user.get_full_name()
5053
email_body = render_to_string("email/local_units/local_unit.html", email_context)
@@ -58,6 +61,14 @@ def send_validate_success_email(local_unit_id: int, message: str = ""):
5861

5962
instance = LocalUnit.objects.get(id=local_unit_id)
6063
user = instance.created_by
64+
if not user:
65+
logger.warning(f"Email not sent for Local Unit:{local_unit_id} because creator is unknown.")
66+
return None
67+
elif not user.email:
68+
logger.warning(
69+
f"Email not sent for Local Unit:{local_unit_id} because creator: {user.get_full_name()} has no email address."
70+
)
71+
return None
6172
email_context = get_email_context(instance)
6273
email_context["full_name"] = user.get_full_name()
6374
email_context["validate_success"] = True
@@ -76,6 +87,14 @@ def send_revert_email(local_unit_id: int, change_request_id: int):
7687
instance = LocalUnit.objects.get(id=local_unit_id)
7788
change_request_instance = LocalUnitChangeRequest.objects.get(id=change_request_id)
7889
user = instance.created_by
90+
if not user:
91+
logger.warning(f"Email not sent for Local Unit:{local_unit_id} because creator is unknown.")
92+
return None
93+
elif not user.email:
94+
logger.warning(
95+
f"Email not sent for Local Unit:{local_unit_id} because creator: {user.get_full_name()} has no email address."
96+
)
97+
return None
7998
email_context = get_email_context(instance)
8099
email_context["full_name"] = user.get_full_name()
81100
email_context["revert_reason"] = change_request_instance.rejected_reason
@@ -94,6 +113,15 @@ def send_deprecate_email(local_unit_id: int):
94113

95114
instance = LocalUnit.objects.get(id=local_unit_id)
96115
user = instance.created_by
116+
if not user:
117+
logger.warning(f"Email not sent for Local Unit:{local_unit_id} because creator is unknown.")
118+
return None
119+
elif not user.email:
120+
logger.warning(
121+
f"Email not sent for Local Unit:{local_unit_id} because creator: {user.get_full_name()} has no email address."
122+
)
123+
return None
124+
97125
email_context = get_email_context(instance)
98126
email_context["full_name"] = user.get_full_name()
99127
email_context["deprecate_local_unit"] = True

local_units/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def get_email_context(instance):
1414
email_context = {
1515
"id": local_unit_data["id"],
1616
"local_branch_name": local_unit_data["local_branch_name"],
17-
"frontend_url": settings.FRONTEND_URL,
17+
"country": local_unit_data["country_details"]["name"],
18+
"country_id": local_unit_data["country_details"]["id"],
19+
"update_reason_overview": local_unit_data["update_reason_overview"],
20+
"frontend_url": settings.GO_WEB_URL,
1821
}
1922
return email_context
2023

notifications/templates/design/foot1.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<table width="100%" border="0" cellspacing="0" cellpadding="0">
99
<tr>
1010
<td class="text-default td-smaller-font-style text-right pl-10 pr-10" style="color: #000000;font-family:'Lato', Arial, sans-serif;border-right:1px solid #000;font-size: 16px;text-align: right;padding-left: 10px;padding-right: 10px;">
11-
<a href="https://go.ifrc.org/login" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">Login to IFRC GO</a>
11+
<a href="{{ frontend_url }}/login" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">Login to IFRC GO</a>
1212
</td>
1313
{% if not hide_preferences %}
1414
<td class="text-default td-smaller-font-style pl-10 pr-10" style="color: #000000;font-family:'Lato', Arial, sans-serif;font-size: 16px;padding-left: 10px;padding-right: 10px;">
15-
<a href="https://go.ifrc.org/account#notifications" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">Unsubscribe</a>
15+
<a href="https://go.ifrc.org/account#notifications" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">Unsubscribe</a>
1616
</td>
1717
{% endif %}
1818
</tr>

notifications/templates/design/foot2.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
<!-- Footer -->
1+
<!-- Footer -->
22
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
33
<tr>
4-
<td valign="top" align="center" class="pt-50 pb-50" style="padding-top: 50px; padding-bottom: 50px;">
4+
<td valign="top" align="center" class="pt-50 pb-50">
55
<table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell">
66
<tr>
77
<td class="td td-shell" style="padding: 0;margin: 0;">
88
<table width="100%" border="0" cellspacing="0" cellpadding="0">
99
<tr>
10-
<td class="text-default text-right pr-10" style="padding-right: 10px;border-right:1px solid #000;text-align: right;font-style: normal;font-weight: 300;font-size: 12px;line-height: 18px">
11-
<a href="https://go.ifrc.org/login" target="_blank" class="link" style="font-family: Poppins, Arial, sans-serif;text-decoration: underline;color: #000;">Login to IFRC GO</a>
10+
<td class="text-default td-smaller-font-style text-right pl-10 pr-10" style="color: #000000;font-family:'Lato', Arial, sans-serif;border-right:1px solid #000;font-size: 16px;text-align: right;padding-left: 10px;padding-right: 10px;">
11+
<a href="{{ frontend_url }}/login" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">Login to IFRC GO</a>
1212
</td>
1313
{% if not hide_preferences %}
14-
{% for record in records|slice:":1" %}
15-
<td class="text-default pl-10" style="padding-left: 10px;font-style: normal;font-weight: 300;font-size: 12px;line-height: 18px">
16-
<a href="https://{{ record.frontend_url }}/account#notifications" target="_blank" class="link" style="font-family: Poppins, Arial, sans-serif;text-decoration: underline;color: #000;">Unsubscribe</a>
14+
<td class="text-default td-smaller-font-style pl-10 pr-10" style="color: #000000;font-family:'Lato', Arial, sans-serif;font-size: 16px;padding-left: 10px;padding-right: 10px;">
15+
<a href="{{ frontend_url }}/account#notifications" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">Unsubscribe</a>
1716
</td>
18-
{% endfor %}
1917
{% endif %}
2018
</tr>
2119
</table>

notifications/templates/email/local_units/local_unit.html

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,54 @@ <h3>Dear {{full_name}}</h3>
99
<tr>
1010
{% if new_local_unit %}
1111
<td align="center" class="pb-30">
12-
A new local unit "{{local_branch_name}}" has been added and is awaiting your validation. Kindly review the information and validate or delete as necessary.
12+
A new local unit "{{local_branch_name}}" in {{country}} has been added and is awaiting your validation. Please review the details and validate or delete as necessary.
13+
You can view the new local unit <a href="{{ frontend_url }}/countries/{{country_id}}/ns-overview/context-and-structure" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">here.</a>
1314
</td>
1415
{% endif %}
1516

1617
{% if update_local_unit %}
1718
<td align="center" class="pb-30">
18-
The local unit "{{local_branch_name}}" has been updated and is awaiting your validation. Kindly review the information and validate or delete as necessary.
19+
The local unit "{{local_branch_name}}" in {{country}} has been updated. Reason:"{{update_reason_overview}}" and is awaiting your validation. Kindly review the information and validate or delete as necessary.
20+
You can view the updated local unit <a href="{{ frontend_url }}/countries/{{country_id}}/ns-overview/context-and-structure" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">here.</a>
1921
</td>
2022
{% endif %}
2123

2224
{% if validate_success %}
2325
<td align="center" class="pb-30">
24-
Your request for the local unit "{{local_branch_name}}" has been successfully validated. The local unit is now visible and marked as validated.
26+
Your request for the local unit "{{local_branch_name}}" in {{country}} has been successfully validated. The local unit is now visible and marked as validated.
27+
You can view the validated local unit <a href="{{ frontend_url }}/countries/{{country_id}}/ns-overview/context-and-structure" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">here.</a>
2528
</td>
2629
{% endif %}
2730

2831
{% if revert_reason %}
2932
<td align="center" class="pb-30">
30-
Your local unit "{{local_branch_name}}" has been reverted. {{revert_reason}}. Please review and resubmit if applicable.
33+
Your local unit "{{local_branch_name}}" in {{country}} has been reverted. Reason: {{revert_reason}}. Please review and resubmit if applicable.
3134
</td>
3235
{% endif %}
3336

3437
{% if deprecate_local_unit %}
3538
<td align="center" class="pb-30">
36-
Your local unit "{{local_branch_name}}" has been deprecated. {{deprecate_reason}}. Please contact the administrator for more information.
39+
Your local unit "{{local_branch_name}}" in {{country}} has been deprecated. Reason: {{deprecate_reason}}. Please contact the administrator for more information.
3740
</td>
3841
{% endif %}
3942

4043
{% if is_validator_regional_admin %}
4144
<td align="center" class="pb-30">
42-
The new local unit "{{local_branch_name}}" has been pending validation for over 7 days. Kindly review and validate or delete as necessary.
45+
The new local unit "{{local_branch_name}}" in {{country}} has been pending validation for over 7 days. Kindly review and validate or delete as necessary.
46+
You can view the new local unit <a href="{{ frontend_url }}/countries/{{country_id}}/ns-overview/context-and-structure" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">here.</a>
4347
</td>
4448
{% endif %}
4549

4650
{% if is_validator_global_admin %}
4751
<td align="center" class="pb-30">
48-
The new local unit "{{local_branch_name}}" has been pending validation for over 14 days and requires your attention. Please review and validate
52+
The new local unit "{{local_branch_name}}" in {{country}} has been pending validation for over 14 days and requires your attention. Please review and validate
4953
or delete as necessary.
54+
You can view the new local unit <a href="{{ frontend_url }}/countries/{{country_id}}/ns-overview/context-and-structure" target="_blank" class="link" style="font-family: 'Lato', Arial, sans-serif;text-decoration: underline;color: #000;">here.</a>
5055
</td>
5156
{% endif %}
5257

5358
</tr>
5459
</table>
5560
<p>Thank you for your attention to this matter.</p>
5661

57-
{% include "design/foot1.html" %}
62+
{% include "design/foot2.html" %}

0 commit comments

Comments
 (0)