-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add OrderFulfill endpoint and LMS enrollment signal (#47)
REV-2847
- Loading branch information
1 parent
ebefa7b
commit b475a5a
Showing
8 changed files
with
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
LMS app signals and receivers. | ||
""" | ||
import logging | ||
|
||
from commerce_coordinator.apps.core.signal_helpers import CoordinatorSignal, coordinator_receiver | ||
from commerce_coordinator.apps.lms.tasks import fulfill_order_placed_send_enroll_in_course_task | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
fulfill_order_placed_signal = CoordinatorSignal() | ||
|
||
|
||
@coordinator_receiver(logger) | ||
def fulfill_order_placed_send_enroll_in_course(**kwargs): | ||
""" | ||
Fulfill the order placed in Titan with a Celery task to LMS to enroll a user in a single course. | ||
""" | ||
fulfill_order_placed_send_enroll_in_course_task.delay( | ||
coupon_code=kwargs['coupon_code'], | ||
course_id=kwargs['course_id'], | ||
date_placed=kwargs['date_placed'], | ||
edx_lms_user_id=kwargs['edx_lms_user_id'], | ||
edx_lms_username=kwargs['edx_lms_username'], | ||
mode=kwargs['mode'], | ||
partner_sku=kwargs['partner_sku'], | ||
titan_order_uuid=kwargs['titan_order_uuid'], | ||
) |
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,35 @@ | ||
""" | ||
LMS Celery tasks | ||
""" | ||
from celery import shared_task | ||
from celery.utils.log import get_task_logger | ||
|
||
# Use the special Celery logger for our tasks | ||
logger = get_task_logger(__name__) | ||
|
||
|
||
@shared_task() | ||
def fulfill_order_placed_send_enroll_in_course_task( | ||
coupon_code, | ||
course_id, | ||
date_placed, | ||
edx_lms_user_id, | ||
edx_lms_username, | ||
mode, | ||
partner_sku, | ||
titan_order_uuid, | ||
): | ||
""" | ||
Celery task for order placed fulfillment and enrollment via LMS Enrollment API. | ||
""" | ||
logger.info( | ||
f'LMS fulfill_order_placed_send_enroll_in_course_task fired with coupon {coupon_code},' | ||
f'course ID {course_id}, on {date_placed}, for LMS user ID {edx_lms_user_id}, with mode {mode},' | ||
f'SKU {partner_sku}, for Titan Order: {titan_order_uuid}.' | ||
) | ||
|
||
# TODO: make the API call to LMS here. | ||
# Temporary if statement below since username is PII and cannot | ||
# be logged but will be used as enrollment data in the next commit | ||
if edx_lms_username: | ||
logger.info('Calling LMS enrollment API...') |
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
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
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