From d408f174e3413cf5c2df526c3014e69186ec71b3 Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Fri, 18 Apr 2014 10:13:19 -0400 Subject: [PATCH] Wording for batch beta email add with autoenroll (LMS-2551) --- lms/djangoapps/instructor/tests/test_api.py | 42 +++++++++++++++++++ lms/djangoapps/instructor/views/api.py | 2 +- .../emails/add_beta_tester_email_message.txt | 6 ++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index 5753c30423..daf46a3db5 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -845,6 +845,48 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe ) ) + def test_add_notenrolled_with_email_autoenroll(self): + url = reverse('bulk_beta_modify_access', kwargs={'course_id': self.course.id}) + response = self.client.get( + url, + {'identifiers': self.notenrolled_student.email, 'action': 'add', 'email_students': True, 'auto_enroll': True} + ) + self.assertEqual(response.status_code, 200) + + self.assertTrue(CourseBetaTesterRole(self.course.location).has_user(self.notenrolled_student)) + # test the response data + expected = { + "action": "add", + "results": [ + { + "identifier": self.notenrolled_student.email, + "error": False, + "userDoesNotExist": False + } + ] + } + res_json = json.loads(response.content) + self.assertEqual(res_json, expected) + + # Check the outbox + self.assertEqual(len(mail.outbox), 1) + self.assertEqual( + mail.outbox[0].subject, + 'You have been invited to a beta test for Robot Super Course' + ) + + self.assertEqual( + mail.outbox[0].body, + u"Dear {0}\n\nYou have been invited to be a beta tester " + "for Robot Super Course at edx.org by a member of the course staff.\n\n" + "To start accessing course materials, please visit " + "https://edx.org/courses/MITx/999/Robot_Super_Course/\n\n----\n" + "This email was automatically sent from edx.org to {1}".format( + self.notenrolled_student.profile.name, + self.notenrolled_student.email + ) + ) + def test_add_notenrolled_email_mktgsite(self): url = reverse('bulk_beta_modify_access', kwargs={'course_id': self.course.id}) # Try with marketing site enabled diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index ef5ef690b0..293d141efe 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -342,7 +342,7 @@ def bulk_beta_modify_access(request, course_id): email_params = {} if email_students: - email_params = get_email_params(course, auto_enroll=False) + email_params = get_email_params(course, auto_enroll=auto_enroll) for identifier in identifiers: try: diff --git a/lms/templates/emails/add_beta_tester_email_message.txt b/lms/templates/emails/add_beta_tester_email_message.txt index b08a100d4b..5d7d336ae2 100644 --- a/lms/templates/emails/add_beta_tester_email_message.txt +++ b/lms/templates/emails/add_beta_tester_email_message.txt @@ -8,7 +8,11 @@ ${_("You have been invited to be a beta tester for {course_name} at {site_name} site_name=site_name )} -% if course_about_url is not None: +% if auto_enroll: +${_("To start accessing course materials, please visit {course_url}").format( + course_url=course_url + )} +% elif course_about_url is not None: ${_("Visit {course_about_url} to join the course and begin the beta test.").format(course_about_url=course_about_url)} % else: ${_("Visit {site_name} to enroll in the course and begin the beta test.").format(site_name=site_name)}