Files
edx-platform/lms/djangoapps/commerce/http.py
Usman Khalid 6cb62f2697 Rebase upgrade Django to v1.8.5
Please note that this is a squshed commit and the work of:
Symbolist, macdiesel, nedbat, doctoryes, muzaffaryousaf and muhammad-ammar
2015-11-10 15:00:19 -05:00

25 lines
878 B
Python

""" HTTP-related entities. """
from rest_framework.status import HTTP_500_INTERNAL_SERVER_ERROR, 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__(resp_obj=data, status=status)
class InternalRequestErrorResponse(DetailResponse):
""" Response returned when an internal service request fails. """
def __init__(self, internal_message):
message = (
'Call to E-Commerce API failed. Internal Service Message: [{internal_message}]'
.format(internal_message=internal_message)
)
super(InternalRequestErrorResponse, self).__init__(message=message, status=HTTP_500_INTERNAL_SERVER_ERROR)