This new endpoint is intended to replace enrollment API call used on the login+registration page. Instead of directly enrolling students, the view will contact the external e-commerce API (Oscar) to create a new order. Oscar will be responsible for completing the order and enrolling the student. This behavior will only apply to course modes with associated SKUs. All other course mode enrollments will be processed directly by LMS.
22 lines
758 B
Python
22 lines
758 B
Python
""" HTTP-related entities. """
|
|
|
|
from rest_framework.status import HTTP_503_SERVICE_UNAVAILABLE, HTTP_200_OK
|
|
|
|
from util.json_request import JsonResponse
|
|
|
|
|
|
class DetailResponse(JsonResponse):
|
|
""" JSON response that simply contains a detail field. """
|
|
|
|
def __init__(self, message, status=HTTP_200_OK):
|
|
data = {'detail': message}
|
|
super(DetailResponse, self).__init__(object=data, status=status)
|
|
|
|
|
|
class ApiErrorResponse(DetailResponse):
|
|
""" Response returned when calls to the E-Commerce API fail or the returned data is invalid. """
|
|
|
|
def __init__(self):
|
|
message = 'Call to E-Commerce API failed. Order creation failed.'
|
|
super(ApiErrorResponse, self).__init__(message=message, status=HTTP_503_SERVICE_UNAVAILABLE)
|