Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Add enterprise url to offers emails (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lael Birch authored Sep 30, 2020
1 parent 3e720f3 commit 73a95ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
13 changes: 9 additions & 4 deletions ecommerce_worker/sailthru/v1/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ def send_course_refund_email(self, email, refund_id, amount, course_name, order_


@shared_task(bind=True, ignore_result=True)
def send_offer_assignment_email(self, user_email, offer_assignment_id, subject, email_body, site_code=None):
def send_offer_assignment_email(self, user_email, offer_assignment_id, subject, email_body,
site_code=None, base_enterprise_url=''):
"""
Sends the offer assignment email.
Expand All @@ -372,14 +373,16 @@ def send_offer_assignment_email(self, user_email, offer_assignment_id, subject,
subject (str): Email subject.
email_body (str): The body of the email.
site_code (str): Identifier of the site sending the email.
base_enterprise_url (str): Url for the enterprise learner portal.
"""
config = get_sailthru_configuration(site_code)
notification = Notification(
config=config,
emails=user_email,
email_vars={
'subject': subject,
'email_body': email_body
'email_body': email_body,
'base_enterprise_url': base_enterprise_url,
},
logger_prefix="Offer Assignment",
site_code=site_code,
Expand All @@ -392,8 +395,10 @@ def send_offer_assignment_email(self, user_email, offer_assignment_id, subject,
if response and response.is_ok():
send_id = response.get_body().get('send_id') # pylint: disable=no-member
if _update_assignment_email_status(offer_assignment_id, send_id, 'success'):
logger.info('[Offer Assignment] Offer assignment notification sent with message --- {message}'.format(
message=email_body))
logger.info('[Offer Assignment] Offer assignment notification sent with message --- ' +
'{message}; base enterprise url --- {base_enterprise_url}'.format(
message=email_body,
base_enterprise_url=base_enterprise_url))
else:
logger.exception(
'[Offer Assignment] An error occurred while updating email status data for '
Expand Down
8 changes: 6 additions & 2 deletions ecommerce_worker/sailthru/v1/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,12 +684,14 @@ class SendOfferEmailsTests(BaseSendEmailTests):
SUBJECT = 'New edX course assignment'
EMAIL_BODY = 'Template message with [email protected] GIL7RUEOU7VHBH7Q ' \
'http://tempurl.url/enroll 3 2012-04-23'
BASE_ENTERPRISE_URL = 'https://bears.party'

ASSIGNMENT_TASK_KWARGS = {
'user_email': USER_EMAIL,
'offer_assignment_id': OFFER_ASSIGNMENT_ID,
'subject': SUBJECT,
'email_body': EMAIL_BODY,
'base_enterprise_url': BASE_ENTERPRISE_URL,
}

UPDATE_TASK_KWARGS = {
Expand Down Expand Up @@ -889,8 +891,10 @@ def test_message_sent(self, mock_update_assignment):
(
self.LOG_TASK_NAME,
'INFO',
'[Offer Assignment] Offer assignment notification sent with message --- {message}'.format(
message=self.EMAIL_BODY
'[Offer Assignment] Offer assignment notification sent with message --- ' +
'{message}; base enterprise url --- {base_enterprise_url}'.format(
message=self.EMAIL_BODY,
base_enterprise_url=self.BASE_ENTERPRISE_URL
)
),
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def is_requirement(line):

setup(
name='edx-ecommerce-worker',
version='0.8.6',
version='0.8.7',
description='Celery tasks supporting the operations of edX\'s ecommerce service',
long_description=long_description,
classifiers=[
Expand Down

0 comments on commit 73a95ee

Please sign in to comment.