Skip to content

Commit 21cc1db

Browse files
authored
Fix missing org name (short and long) in email templates (#4638)
I noticed that the signature of the application notification emails was off: ``` Kind Regards, The Team -- http://example.com ``` While investigating I found out that the `base.html` email template was using `org_long_name` instead of `ORG_LONG_NAME` (which is what the `global_vars` [context processor](https://github.com/HyphaApp/hypha/blob/d26405a02bf8ef8ac348992c3a12f6c100f82bab/hypha/core/context_processors.py#L6) is providing). This issue appears to be widespread, and it's not helped by the fact that some emails correctly receive the `org_long_name` variable (it's passed manually in the context). For this PR, I went with the exhaustive approach of replacing every single instance of `org_long_name`, `org_short_name`, and `org_email` with their uppercase counterparts: ``` git grep -lw org_long_name | xargs sed -i 's/\borg_long_name\b/ORG_LONG_NAME/' git grep -lw org_short_name | xargs sed -i 's/\borg_short_name\b/ORG_SHORT_NAME/' git grep -lw org_email | xargs sed -i 's/\borg_email\b/ORG_EMAIL/' ```
1 parent b48822e commit 21cc1db

File tree

29 files changed

+318
-366
lines changed

29 files changed

+318
-366
lines changed

hypha/apply/activity/adapters/emails.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ def get_subject(self, message_type, source):
150150
else:
151151
try:
152152
subject = source.page.specific.subject or _(
153-
"Your application to {org_long_name}: {source.title_text_display}"
154-
).format(org_long_name=settings.ORG_LONG_NAME, source=source)
153+
"Your application to {ORG_LONG_NAME}: {source.title_text_display}"
154+
).format(ORG_LONG_NAME=settings.ORG_LONG_NAME, source=source)
155155
except AttributeError:
156-
subject = _("Your {org_long_name} Project: {source.title}").format(
157-
org_long_name=settings.ORG_LONG_NAME, source=source
156+
subject = _("Your {ORG_LONG_NAME} Project: {source.title}").format(
157+
ORG_LONG_NAME=settings.ORG_LONG_NAME, source=source
158158
)
159159
return subject
160160

hypha/apply/activity/templates/messages/email/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
{% block more_info %}{% endblock %}
77

88
{# fmt:off #}{% blocktrans %}Kind Regards,
9-
The {{ org_short_name }} Team{% endblocktrans %}
9+
The {{ ORG_SHORT_NAME }} Team{% endblocktrans %}
1010

1111
--
12-
{{ org_long_name }}
12+
{{ ORG_LONG_NAME }}
1313
{% if ORG_URL %}{{ ORG_URL }}{% endif %}
1414
{% block post_signature_content %}{% endblock %}{# fmt:on #}

hypha/apply/funds/workflows/definitions/double_stage.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
"invited_to_proposal": _("Invite to Proposal"),
7373
},
7474
"display": _("Internal Review"),
75-
"public": _("{org_short_name} Review").format(
76-
org_short_name=settings.ORG_SHORT_NAME
75+
"public": _("{ORG_SHORT_NAME} Review").format(
76+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
7777
),
7878
"stage": Concept,
7979
"permissions": default_permissions,
@@ -209,8 +209,8 @@
209209
"proposal_discussion": _("Proposal Received (revert)"),
210210
},
211211
"display": _("Internal Review"),
212-
"public": _("{org_short_name} Review").format(
213-
org_short_name=settings.ORG_SHORT_NAME
212+
"public": _("{ORG_SHORT_NAME} Review").format(
213+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
214214
),
215215
"stage": Proposal,
216216
"permissions": default_permissions,

hypha/apply/funds/workflows/definitions/single_stage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
INITIAL_STATE: _("Need screening (revert)"),
7373
},
7474
"display": _("Internal Review"),
75-
"public": _("{org_short_name} Review").format(
76-
org_short_name=settings.ORG_SHORT_NAME
75+
"public": _("{ORG_SHORT_NAME} Review").format(
76+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
7777
),
7878
"stage": Request,
7979
"permissions": default_permissions,

hypha/apply/funds/workflows/definitions/single_stage_community.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
"com_rejected": _("Dismiss"),
8282
},
8383
"display": _("Internal Review"),
84-
"public": _("{org_short_name} Review").format(
85-
org_short_name=settings.ORG_SHORT_NAME
84+
"public": _("{ORG_SHORT_NAME} Review").format(
85+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
8686
),
8787
"stage": RequestCom,
8888
"permissions": default_permissions,
@@ -94,8 +94,8 @@
9494
"com_rejected": _("Dismiss"),
9595
},
9696
"display": _("Community Review"),
97-
"public": _("{org_short_name} Review").format(
98-
org_short_name=settings.ORG_SHORT_NAME
97+
"public": _("{ORG_SHORT_NAME} Review").format(
98+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
9999
),
100100
"stage": RequestCom,
101101
"permissions": community_review_permissions,

hypha/apply/funds/workflows/definitions/single_stage_external.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
INITIAL_STATE: _("Need screening (revert)"),
6868
},
6969
"display": _("Internal Review"),
70-
"public": _("{org_short_name} Review").format(
71-
org_short_name=settings.ORG_SHORT_NAME
70+
"public": _("{ORG_SHORT_NAME} Review").format(
71+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
7272
),
7373
"stage": RequestExt,
7474
"permissions": default_permissions,

hypha/apply/funds/workflows/definitions/single_stage_same.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
INITIAL_STATE: _("Need screening (revert)"),
6868
},
6969
"display": _("Review"),
70-
"public": _("{org_short_name} Review").format(
71-
org_short_name=settings.ORG_SHORT_NAME
70+
"public": _("{ORG_SHORT_NAME} Review").format(
71+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
7272
),
7373
"stage": RequestSame,
7474
"permissions": reviewer_review_permissions,

hypha/apply/projects/templatetags/project_tags.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def user_next_step_on_project(project, user, request=None):
123123
return {
124124
"heading": _("Waiting for"),
125125
"text": _(
126-
"Awaiting project documents to be created and approved by {org_short_name} internally. "
126+
"Awaiting project documents to be created and approved by {ORG_SHORT_NAME} internally. "
127127
"Please check back when the project has moved to contracting stage."
128-
).format(org_short_name=settings.ORG_SHORT_NAME),
128+
).format(ORG_SHORT_NAME=settings.ORG_SHORT_NAME),
129129
}
130130
if project.paf_approvals.exists():
131131
return {
@@ -141,9 +141,9 @@ def user_next_step_on_project(project, user, request=None):
141141
return {
142142
"heading": _("Waiting for"),
143143
"text": _(
144-
"Awaiting project documents to be created and approved by {org_short_name} internally. "
144+
"Awaiting project documents to be created and approved by {ORG_SHORT_NAME} internally. "
145145
"Please check back when the project has moved to contracting stage."
146-
).format(org_short_name=settings.ORG_SHORT_NAME),
146+
).format(ORG_SHORT_NAME=settings.ORG_SHORT_NAME),
147147
}
148148

149149
if request:
@@ -216,8 +216,8 @@ def user_next_step_on_project(project, user, request=None):
216216
if user.is_applicant:
217217
return {
218218
"heading": _("Waiting for"),
219-
"text": _("Awaiting signed contract from {org_short_name}").format(
220-
org_short_name=settings.ORG_SHORT_NAME
219+
"text": _("Awaiting signed contract from {ORG_SHORT_NAME}").format(
220+
ORG_SHORT_NAME=settings.ORG_SHORT_NAME
221221
),
222222
}
223223
if settings.STAFF_UPLOAD_CONTRACT:
@@ -265,8 +265,8 @@ def user_next_step_on_project(project, user, request=None):
265265
return {
266266
"heading": _("Waiting for"),
267267
"text": _(
268-
"Awaiting contract approval from {org_short_name}"
269-
).format(org_short_name=settings.ORG_SHORT_NAME),
268+
"Awaiting contract approval from {ORG_SHORT_NAME}"
269+
).format(ORG_SHORT_NAME=settings.ORG_SHORT_NAME),
270270
}
271271
return {
272272
"heading": _("Waiting for"),
@@ -300,8 +300,8 @@ def user_next_step_instructions(project, user):
300300
if contract and not contract.signed_by_applicant:
301301
return [
302302
_(
303-
"Please download the signed contract uploaded by {org_short_name}"
304-
).format(org_short_name=settings.ORG_SHORT_NAME),
303+
"Please download the signed contract uploaded by {ORG_SHORT_NAME}"
304+
).format(ORG_SHORT_NAME=settings.ORG_SHORT_NAME),
305305
_("Countersign"),
306306
_("Upload it back"),
307307
_(

hypha/apply/users/services.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ def _get_url_params(self) -> None | str:
9494

9595
def get_email_context(self) -> dict:
9696
return {
97-
"org_long_name": settings.ORG_LONG_NAME,
98-
"org_email": settings.ORG_EMAIL,
99-
"org_short_name": settings.ORG_SHORT_NAME,
97+
"ORG_LONG_NAME": settings.ORG_LONG_NAME,
98+
"ORG_EMAIL": settings.ORG_EMAIL,
99+
"ORG_SHORT_NAME": settings.ORG_SHORT_NAME,
100100
"site": self.site,
101101
}
102102

103103
def send_email_no_account_found(self, to):
104104
context = self.get_email_context()
105-
subject = "Log in attempt at {org_long_name}".format(**context)
105+
subject = "Log in attempt at {ORG_LONG_NAME}".format(**context)
106106
# Force subject to a single line to avoid header-injection issues.
107107
subject = "".join(subject.splitlines())
108108

@@ -130,7 +130,7 @@ def send_login_email(self, user):
130130
}
131131
)
132132

133-
subject = "Log in to {username} at {org_long_name}".format(**context)
133+
subject = "Log in to {username} at {ORG_LONG_NAME}".format(**context)
134134
# Force subject to a single line to avoid header-injection issues.
135135
subject = "".join(subject.splitlines())
136136

@@ -154,7 +154,7 @@ def send_new_account_login_email(self, signup_obj):
154154
}
155155
)
156156

157-
subject = "Welcome to {org_long_name}".format(**context)
157+
subject = "Welcome to {ORG_LONG_NAME}".format(**context)
158158
# Force subject to a single line to avoid header-injection issues.
159159
subject = "".join(subject.splitlines())
160160

hypha/apply/users/templates/users/activation/email.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load i18n wagtailadmin_tags %}{% base_url_setting as base_url %}{% firstof name username as user %}
22
{% blocktrans %}Dear {{ user }},{% endblocktrans %}
33

4-
{% blocktrans %}Activate your account on the {{ org_long_name }} web site by clicking this link or copying and pasting it to your browser:{% endblocktrans %}
4+
{% blocktrans %}Activate your account on the {{ ORG_LONG_NAME }} web site by clicking this link or copying and pasting it to your browser:{% endblocktrans %}
55

66
{% if site %}{{ site.root_url }}{% else %}{{ base_url }}{% endif %}{{ activation_path }}
77

@@ -15,8 +15,8 @@
1515
{% blocktrans %}If you do not complete the activation process within {{ timeout_days }} days you can use the password reset form at{% endblocktrans %}: {% if site %}{{ site.root_url }}{% else %}{{ base_url }}{% endif %}{% url 'users:password_reset' %}
1616

1717
{% blocktrans %}Kind Regards,
18-
The {{ org_short_name }} Team{% endblocktrans %}
18+
The {{ ORG_SHORT_NAME }} Team{% endblocktrans %}
1919

2020
--
21-
{{ org_long_name }}
21+
{{ ORG_LONG_NAME }}
2222
{% if site %}{{ site.root_url }}{% else %}{{ base_url }}{% endif %}

0 commit comments

Comments
 (0)