From df0bb491fa70fbe7cb700c60106df3b7d04d965f Mon Sep 17 00:00:00 2001 From: Muhammad Shoaib Date: Tue, 18 Nov 2014 18:13:17 +0500 Subject: [PATCH] WL-99 send a copy of the invoice to the finance@edx.org when registration codes are generated changed the finance_email in the common.py file added the test for the FiNANCE_EMAIL settings --- lms/djangoapps/instructor/tests/test_api.py | 24 +++++++++++++++++++++ lms/djangoapps/instructor/views/api.py | 5 +++++ lms/envs/aws.py | 1 + lms/envs/common.py | 1 + 4 files changed, 31 insertions(+) diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index a9900889c1..1ca5bba6ac 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -3010,6 +3010,30 @@ class TestCourseRegistrationCodes(ModuleStoreTestCase): ) registration_code_redemption.save() + @override_settings(FINANCE_EMAIL='finance@example.com') + def test_finance_email_in_recipient_list_when_generating_registration_codes(self): + """ + Test to verify that the invoice will also be sent to the FINANCE_EMAIL when + generating registration codes + """ + url_reg_code = reverse('generate_registration_codes', + kwargs={'course_id': self.course.id.to_deprecated_string()}) + + data = { + 'total_registration_codes': 5, 'company_name': 'Group Alpha', 'company_contact_name': 'Test@company.com', + 'company_contact_email': 'Test@company.com', 'sale_price': 121.45, 'recipient_name': 'Test123', + 'recipient_email': 'test@123.com', 'address_line_1': 'Portland Street', 'address_line_2': '', + 'address_line_3': '', 'city': '', 'state': '', 'zip': '', 'country': '', + 'customer_reference_number': '123A23F', 'internal_reference': '', 'invoice': 'True' + } + + response = self.client.post(url_reg_code, data, **{'HTTP_HOST': 'localhost'}) + self.assertEqual(response.status_code, 200, response.content) + self.assertEqual(response['Content-Type'], 'text/csv') + # check for the last mail.outbox, The FINANCE_EMAIL has been appended at the + # very end, when generating registration codes + self.assertEqual(mail.outbox[-1].to[0], 'finance@example.com') + def test_user_invoice_copy_preference(self): """ Test to remember user invoice copy preference diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 901dab3533..f8176c9ce0 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -1157,6 +1157,11 @@ def generate_registration_codes(request, course_id): for registration_code in registration_codes: csv_writer.writerow([registration_code.code]) + finance_email = microsite.get_value('finance_email', settings.FINANCE_EMAIL) + if finance_email: + # append the finance email into the recipient_list + recipient_list.append(finance_email) + # send a unique email for each recipient, don't put all email addresses in a single email for recipient in recipient_list: email = EmailMessage() diff --git a/lms/envs/aws.py b/lms/envs/aws.py index dc090aef5a..b6f351c9bb 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -180,6 +180,7 @@ TECH_SUPPORT_EMAIL = ENV_TOKENS.get('TECH_SUPPORT_EMAIL', TECH_SUPPORT_EMAIL) CONTACT_EMAIL = ENV_TOKENS.get('CONTACT_EMAIL', CONTACT_EMAIL) BUGS_EMAIL = ENV_TOKENS.get('BUGS_EMAIL', BUGS_EMAIL) PAYMENT_SUPPORT_EMAIL = ENV_TOKENS.get('PAYMENT_SUPPORT_EMAIL', PAYMENT_SUPPORT_EMAIL) +FINANCE_EMAIL = ENV_TOKENS.get('FINANCE_EMAIL', FINANCE_EMAIL) UNIVERSITY_EMAIL = ENV_TOKENS.get('UNIVERSITY_EMAIL', UNIVERSITY_EMAIL) PRESS_EMAIL = ENV_TOKENS.get('PRESS_EMAIL', PRESS_EMAIL) diff --git a/lms/envs/common.py b/lms/envs/common.py index ec73c49a11..7d42ddbdf0 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -668,6 +668,7 @@ CONTACT_EMAIL = 'info@example.com' BUGS_EMAIL = 'bugs@example.com' UNIVERSITY_EMAIL = 'university@example.com' PRESS_EMAIL = 'press@example.com' +FINANCE_EMAIL = '' ADMINS = () MANAGERS = ADMINS