Files
edx-platform/lms/djangoapps/commerce/http.py
Feanil Patel 9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00

27 lines
881 B
Python

""" HTTP-related entities. """
from rest_framework.status import HTTP_200_OK, HTTP_500_INTERNAL_SERVER_ERROR
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 = (
u'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)