From 80dac4b8bb2a834b1b1fda07322aca61095b6ad5 Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Mon, 30 Oct 2023 10:57:51 +0000 Subject: [PATCH 1/6] update training request autoresponse --- .../tests/test_training_request_form.py | 32 +++++++++++++++++++ .../includes/trainingrequest_details.html | 2 ++ amy/templates/mailing/training_request.txt | 5 ++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/amy/extforms/tests/test_training_request_form.py b/amy/extforms/tests/test_training_request_form.py index 9b4791701..a8a71a097 100644 --- a/amy/extforms/tests/test_training_request_form.py +++ b/amy/extforms/tests/test_training_request_form.py @@ -13,6 +13,9 @@ class TestTrainingRequestForm(TestBase): INVALID_MEMBER_CODE_ERROR = "This code is invalid." + MEMBER_CODE_OVERRIDE_EMAIL_TEXT = ( + "Continue with registration code marked as invalid" + ) def setUp(self): self._setUpUsersAndLogin() @@ -123,6 +126,7 @@ def test_request_added(self): self.assertEqual(msg.to, [email]) self.assertEqual(msg.subject, TrainingRequestCreate.autoresponder_subject) self.assertIn("A copy of your request", msg.body) + self.assertNotIn(self.MEMBER_CODE_OVERRIDE_EMAIL_TEXT, msg.body) def test_invalid_request_not_added(self): # Arrange @@ -419,3 +423,31 @@ def test_member_code_validation__code_valid_override_full_request(self): self.assertFalse( TrainingRequest.objects.get(member_code="valid123").member_code_override ) + + # Test that the sender was emailed with correct content + self.assertEqual(len(mail.outbox), 1) + msg = mail.outbox[0] + self.assertNotIn(self.MEMBER_CODE_OVERRIDE_EMAIL_TEXT, msg.body) + + def test_member_code_validation__code_invalid_override_full_request(self): + """Sent email should include the member_code_override field if used.""" + # Arrange + self.setUpMembership() + self.data["member_code"] = "invalid" + self.data["member_code_override"] = True + self.passCaptcha(self.data) + + # Act + rv = self.client.post(reverse("training_request"), data=self.data, follow=True) + + # Assert + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv.resolver_match.view_name, "training_request_confirm") + self.assertTrue( + TrainingRequest.objects.get(member_code="invalid").member_code_override + ) + + # Test that the sender was emailed with correct content + self.assertEqual(len(mail.outbox), 1) + msg = mail.outbox[0] + self.assertIn(self.MEMBER_CODE_OVERRIDE_EMAIL_TEXT, msg.body) diff --git a/amy/templates/includes/trainingrequest_details.html b/amy/templates/includes/trainingrequest_details.html index c874c1dfc..80ac3eaa3 100644 --- a/amy/templates/includes/trainingrequest_details.html +++ b/amy/templates/includes/trainingrequest_details.html @@ -26,8 +26,10 @@ {{ object.get_review_process_display|default:"—" }} Registration Code: {{ object.member_code|default:"—" }} +{% if admin or object.member_code_override %} Continue with registration code marked as invalid: {{ object.member_code_override|yesno }} +{% endif %} Personal name: {{ object.personal }} Middle name: diff --git a/amy/templates/mailing/training_request.txt b/amy/templates/mailing/training_request.txt index 3dd6ca81d..0fad329e1 100644 --- a/amy/templates/mailing/training_request.txt +++ b/amy/templates/mailing/training_request.txt @@ -7,7 +7,7 @@ Open Training applications are placed in an application queue to be considered f If you have a specific need to be trained sooner (e.g. an upcoming workshop) please let us know. Multiple applicants from a single institution generally will not be invited at once, but may be accepted individually over time. To more rapidly build an Instructor community at your institution, consider becoming a Member. For more information see: https://carpentries.org/membership/ or get in touch with memberships@carpentries.org to learn more about how we can help you make the case at your organisation. -We receive hundreds of applications, and we cannot provide no-cost training for every applicant. Please, don't let that discourage you! We'd like to help you bring workshops and instructor training to your organisation. In the meantime, please get involved! +We receive hundreds of applications, and we cannot provide no-cost training for every applicant. Please, don't let that discourage you! We'd like to help you bring workshops and instructor training to your organisation. In the meantime, please get involved! Join our discussion email list: https://carpentries.topicbox.com/groups/discuss @@ -30,6 +30,9 @@ A copy of your request is included below for your reference. Submission date: {{ object.created_at }} Application Type: {{ object.get_review_process_display|default:"---" }} Registration Code: {{ object.member_code|default:"—" }} +{% if object.member_code_override %} +Continue with registration code marked as invalid: {{object.member_code_override|yesno}} +{% endif %} Person: {{object.personal}} {{object.middle}} {{object.family}} <{{object.email}}> Github: {{ object.github|default:"---" }} Occupation: {{ object.get_occupation_display }} {{ object.occupation_other }} From e3927c0e9735687bfacc93a30af84d34b177c563 Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Mon, 30 Oct 2023 11:05:38 +0000 Subject: [PATCH 2/6] add warnings to TR template for invalid member code --- amy/templates/mailing/training_request.html | 10 ++++++++++ amy/templates/mailing/training_request.txt | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/amy/templates/mailing/training_request.html b/amy/templates/mailing/training_request.html index 3afed95ce..73d0566fe 100644 --- a/amy/templates/mailing/training_request.html +++ b/amy/templates/mailing/training_request.html @@ -50,5 +50,15 @@ The Carpentries Instructor Training Team

+
+ +A copy of your request is included below for your reference. + +{% if object.member_code_override %} +

+ Warning: Your registration code "{object.member_code}" seems to be invalid. + A member of our team will check the code and follow up with you if there are any problems that require your attention. +

+{% endif %} {% include "includes/trainingrequest_details.html" with admin=False object=object %} diff --git a/amy/templates/mailing/training_request.txt b/amy/templates/mailing/training_request.txt index 0fad329e1..f70ba7ca4 100644 --- a/amy/templates/mailing/training_request.txt +++ b/amy/templates/mailing/training_request.txt @@ -27,6 +27,11 @@ The Carpentries Instructor Training Team A copy of your request is included below for your reference. +{% if object.member_code_override %} +**Warning:** Your registration code "{object.member_code}" seems to be invalid. +A member of our team will check the code and follow up with you if there are any problems that require your attention. +{% endif %} + Submission date: {{ object.created_at }} Application Type: {{ object.get_review_process_display|default:"---" }} Registration Code: {{ object.member_code|default:"—" }} From cbe55cf86a6f6fc012d32f8a541c905f39de3b03 Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Mon, 30 Oct 2023 11:06:00 +0000 Subject: [PATCH 3/6] add registration code to workshop request form --- amy/templates/mailing/workshoprequest.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/amy/templates/mailing/workshoprequest.txt b/amy/templates/mailing/workshoprequest.txt index 505569db7..e02427ef1 100644 --- a/amy/templates/mailing/workshoprequest.txt +++ b/amy/templates/mailing/workshoprequest.txt @@ -32,6 +32,7 @@ instructors in such short time. Submission date: {{ object.created_at }} Person: {{ object.personal }} {{ object.family }} <{{ object.email }}> Institution: {% if object.institution %}{{ object.institution }}{% else %}{{ object.institution_other_name }}{% endif %}{% if object.institution_department %}, {{ object.institution_department }}{% endif %} +Member registration code: {{ object.member_code|default:"—" }} Workshop location: {{ object.location }} Country: {{ object.country.name }} Requested workshop types: {% for type in object.requested_workshop_types.all %}{{ type }}{% if not forloop.last %}, {% endif %}{% endfor %} From c6b98ca2aea1e32ea03131f83096526f01bafdab Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Mon, 30 Oct 2023 11:20:54 +0000 Subject: [PATCH 4/6] update TR tests --- .../tests/test_training_request_form.py | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/amy/extforms/tests/test_training_request_form.py b/amy/extforms/tests/test_training_request_form.py index a8a71a097..c3265665c 100644 --- a/amy/extforms/tests/test_training_request_form.py +++ b/amy/extforms/tests/test_training_request_form.py @@ -1,5 +1,6 @@ from datetime import date, timedelta +from django.conf import settings from django.core import mail from django.forms import CheckboxInput, HiddenInput from django.test import override_settings @@ -13,8 +14,9 @@ class TestTrainingRequestForm(TestBase): INVALID_MEMBER_CODE_ERROR = "This code is invalid." - MEMBER_CODE_OVERRIDE_EMAIL_TEXT = ( - "Continue with registration code marked as invalid" + MEMBER_CODE_OVERRIDE_LABEL = "Continue with registration code marked as invalid" + MEMBER_CODE_OVERRIDE_EMAIL_WARNING = ( + "A member of our team will check the code and follow up with you" ) def setUp(self): @@ -111,6 +113,8 @@ def test_request_added(self): # Arrange email = self.data.get("email") self.passCaptcha(self.data) + # before tests, check if the template invalid string exists + self.assertTrue(settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"]) # Act rv = self.client.post(reverse("training_request"), self.data, follow=True) @@ -126,7 +130,11 @@ def test_request_added(self): self.assertEqual(msg.to, [email]) self.assertEqual(msg.subject, TrainingRequestCreate.autoresponder_subject) self.assertIn("A copy of your request", msg.body) - self.assertNotIn(self.MEMBER_CODE_OVERRIDE_EMAIL_TEXT, msg.body) + self.assertNotIn(self.MEMBER_CODE_OVERRIDE_LABEL, msg.body) + self.assertNotIn(self.MEMBER_CODE_OVERRIDE_EMAIL_WARNING, msg.body) + self.assertNotIn( + settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"], msg.body + ) def test_invalid_request_not_added(self): # Arrange @@ -413,6 +421,8 @@ def test_member_code_validation__code_valid_override_full_request(self): self.data["member_code"] = "valid123" self.data["member_code_override"] = True self.passCaptcha(self.data) + # before tests, check if the template invalid string exists + self.assertTrue(settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"]) # Act rv = self.client.post(reverse("training_request"), data=self.data, follow=True) @@ -427,7 +437,11 @@ def test_member_code_validation__code_valid_override_full_request(self): # Test that the sender was emailed with correct content self.assertEqual(len(mail.outbox), 1) msg = mail.outbox[0] - self.assertNotIn(self.MEMBER_CODE_OVERRIDE_EMAIL_TEXT, msg.body) + self.assertNotIn(self.MEMBER_CODE_OVERRIDE_LABEL, msg.body) + self.assertNotIn(self.MEMBER_CODE_OVERRIDE_EMAIL_WARNING, msg.body) + self.assertNotIn( + settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"], msg.body + ) def test_member_code_validation__code_invalid_override_full_request(self): """Sent email should include the member_code_override field if used.""" @@ -436,6 +450,8 @@ def test_member_code_validation__code_invalid_override_full_request(self): self.data["member_code"] = "invalid" self.data["member_code_override"] = True self.passCaptcha(self.data) + # before tests, check if the template invalid string exists + self.assertTrue(settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"]) # Act rv = self.client.post(reverse("training_request"), data=self.data, follow=True) @@ -450,4 +466,8 @@ def test_member_code_validation__code_invalid_override_full_request(self): # Test that the sender was emailed with correct content self.assertEqual(len(mail.outbox), 1) msg = mail.outbox[0] - self.assertIn(self.MEMBER_CODE_OVERRIDE_EMAIL_TEXT, msg.body) + self.assertIn(self.MEMBER_CODE_OVERRIDE_LABEL, msg.body) + self.assertIn(self.MEMBER_CODE_OVERRIDE_EMAIL_WARNING, msg.body) + self.assertNotIn( + settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"], msg.body + ) From 004c51923e11fa2a723b5e2f839639b9310e09ab Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Mon, 30 Oct 2023 11:25:59 +0000 Subject: [PATCH 5/6] add reasons to template warning --- amy/templates/mailing/training_request.html | 3 +-- amy/templates/mailing/training_request.txt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/amy/templates/mailing/training_request.html b/amy/templates/mailing/training_request.html index 73d0566fe..7f7675f1c 100644 --- a/amy/templates/mailing/training_request.html +++ b/amy/templates/mailing/training_request.html @@ -56,8 +56,7 @@ {% if object.member_code_override %}

- Warning: Your registration code "{object.member_code}" seems to be invalid. - A member of our team will check the code and follow up with you if there are any problems that require your attention. + Warning: Your registration code "{{object.member_code}}" seems to be invalid. This may be due to a typo, an expired code, a code that has not yet been activated, or a code with no training seats remaining. A member of our team will check the code and follow up with you if there are any problems that require your attention.

{% endif %} diff --git a/amy/templates/mailing/training_request.txt b/amy/templates/mailing/training_request.txt index f70ba7ca4..270a4dff0 100644 --- a/amy/templates/mailing/training_request.txt +++ b/amy/templates/mailing/training_request.txt @@ -28,8 +28,7 @@ The Carpentries Instructor Training Team A copy of your request is included below for your reference. {% if object.member_code_override %} -**Warning:** Your registration code "{object.member_code}" seems to be invalid. -A member of our team will check the code and follow up with you if there are any problems that require your attention. +**Warning:** Your registration code "{{object.member_code}}" seems to be invalid. This may be due to a typo, an expired code, a code that has not yet been activated, or a code with no training seats remaining. A member of our team will check the code and follow up with you if there are any problems that require your attention. {% endif %} Submission date: {{ object.created_at }} From 7aaf7d2a360a4068db7788189b8ff36af7e33d85 Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Mon, 30 Oct 2023 11:30:22 +0000 Subject: [PATCH 6/6] remove duplicate text --- amy/templates/mailing/training_request.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amy/templates/mailing/training_request.html b/amy/templates/mailing/training_request.html index 7f7675f1c..c754d7315 100644 --- a/amy/templates/mailing/training_request.html +++ b/amy/templates/mailing/training_request.html @@ -16,7 +16,7 @@

- We receive hundreds of applications, and we cannot provide no-cost training for every applicant. Please, don't let that discourage you! We'd like to help you bring workshops and instructor training to your organisation. In the meantime, please get involved! + We receive hundreds of applications, and we cannot provide no-cost training for every applicant. Please, don't let that discourage you! We'd like to help you bring workshops and instructor training to your organisation.

In the meantime, please get involved!