-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update welcome email command to allow per stage templates
- Loading branch information
Showing
3 changed files
with
102 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -799,7 +799,7 @@ class SendWelcomeEmails(BaseCommandTestCase): | |
def test_required_args(self): | ||
self.assertEquals(len(mail.outbox), 0) | ||
with self.assertRaisesRegex( | ||
CommandError, r"following arguments are required: --session" | ||
CommandError, r"following arguments are required: --stage, --session" | ||
): | ||
self.call_command( | ||
"send_welcome_emails", | ||
|
@@ -810,19 +810,22 @@ def test_basic_run(self): | |
self.assertEquals(len(mail.outbox), 0) | ||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
session="Default", | ||
) | ||
self.assertEquals(len(mail.outbox), 0) | ||
|
||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
session="Default", | ||
send_emails=True, | ||
) | ||
self.assertEquals(len(mail.outbox), 2) | ||
|
||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
session="Default", | ||
send_emails=True, | ||
) | ||
|
@@ -837,6 +840,7 @@ def test_only_sends_if_flag_set(self): | |
|
||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
session="Default", | ||
send_emails=True, | ||
) | ||
|
@@ -848,6 +852,7 @@ def test_only_sends_if_flag_set(self): | |
def test_email_comtent(self): | ||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
session="Default", | ||
send_emails=True, | ||
) | ||
|
@@ -883,13 +888,15 @@ def test_limit_session(self): | |
self.assertEquals(len(mail.outbox), 0) | ||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
send_emails=True, | ||
session="Second Session", | ||
) | ||
self.assertEquals(len(mail.outbox), 0) | ||
|
||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
send_emails=True, | ||
session="Default", | ||
) | ||
|
@@ -903,6 +910,7 @@ def test_config_loading(self): | |
self.assertEquals(len(mail.outbox), 0) | ||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
send_emails=True, | ||
session="Second Session", | ||
) | ||
|
@@ -913,18 +921,72 @@ def test_config_loading(self): | |
mail.outbox = [] | ||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
send_emails=True, | ||
session="Default", | ||
) | ||
self.assertEquals(len(mail.outbox), 1) | ||
email = mail.outbox[0] | ||
self.assertEquals(email.from_email, "Default From <[email protected]>") | ||
|
||
@override_settings( | ||
WELCOME_EMAIL={ | ||
"Default": { | ||
"server_name": "example.org", | ||
"from_email": "Default From <[email protected]>", | ||
"subject_template": "registration/initial_password_email_subject.txt", | ||
"new_user_template": "registration/initial_password_email.html", | ||
"previous_user_template": "registration/repeat_password_email.html", | ||
"Right of Reply": { | ||
"subject_template": "registration/council_password_email_subject.txt", | ||
"new_user_template": "registration/council_password_email.html", | ||
"previous_user_template": "registration/council_repeat_password_email.html", | ||
}, | ||
}, | ||
} | ||
) | ||
def test_template_loading(self): | ||
marker = Marker.objects.get(user__email="[email protected]") | ||
rt = ResponseType.objects.get(type="Right of Reply") | ||
marker.response_type = rt | ||
marker.save() | ||
|
||
self.assertEquals(len(mail.outbox), 0) | ||
self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
send_emails=True, | ||
session="Default", | ||
) | ||
self.assertEquals(len(mail.outbox), 1) | ||
email = mail.outbox[0] | ||
self.assertEquals( | ||
email.subject, | ||
"Registration link for CEUK Council Climate Scorecards Scoring System", | ||
) | ||
self.assertRegex(email.body, r"Thanks for volunteering") | ||
|
||
mail.outbox = [] | ||
self.call_command( | ||
"send_welcome_emails", | ||
stage="Right of Reply", | ||
send_emails=True, | ||
session="Default", | ||
) | ||
self.assertEquals(len(mail.outbox), 1) | ||
email = mail.outbox[0] | ||
self.assertEquals( | ||
email.subject, | ||
"Registration link for CEUK Council Climate Scorecards Scoring System", | ||
) | ||
self.assertRegex(email.body, r"council’s contact to receive") | ||
|
||
@override_settings(WELCOME_EMAIL={}) | ||
def test_error_if_no_config(self): | ||
self.assertEquals(len(mail.outbox), 0) | ||
_, err = self.call_command( | ||
"send_welcome_emails", | ||
stage="First Mark", | ||
send_emails=True, | ||
session="Default", | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% autoescape off %} | ||
Hi, | ||
|
||
You're receiving this email because you are your council’s contact to receive the Right of Reply for Climate Emergency UK’s Council Climate Scorecards. This email allows you to log into the online data collection system to submit the Right of Reply and respond to your council’s first mark in the Council Climate Scorecards. | ||
|
||
Please go to the following page and choose a new password: | ||
{% block reset_link %} | ||
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} | ||
{% endblock %} | ||
Your username is {{ user.get_username }} | ||
|
||
Please Note: Multiple people will be able to login to GRACE as long as they have this username and password. Please only share this with relevant staff within your council. We will be unable to set up multiple accounts for your Council. | ||
|
||
You will also receive a second email containing further information, a guide to the Right of Reply process and a recording of the Right of Reply briefing. This email will be sent to every officer contact for your council on our email list. | ||
|
||
Kind Regards, | ||
|
||
The CEUK team. | ||
|
||
{% endautoescape %} | ||
|