response 308 in force update

This commit is contained in:
jain
2023-08-23 12:29:53 +05:30
parent 8d159ac3a4
commit 4e0c6a91f4

View File

@ -18,9 +18,9 @@ from guardian.models import Guardian
# user can login in single
# device at a time"""
def custom_response(custom_error):
def custom_response(custom_error, response_status = status.HTTP_404_NOT_FOUND):
"""custom response"""
response = Response(custom_error.data, status=status.HTTP_404_NOT_FOUND)
response = Response(custom_error.data, status=response_status)
# Set content type header to "application/json"
response['Content-Type'] = 'application/json'
# Render the response as JSON
@ -64,5 +64,5 @@ class CustomMiddleware(object):
if not force_update and version and device_type:
custom_error = custom_error_response(ERROR_CODE['2079'],
response_status=status.HTTP_308_PERMANENT_REDIRECT)
response = custom_response(custom_error)
response = custom_response(custom_error, status.HTTP_308_PERMANENT_REDIRECT)
return response