force update not affect admin's api

This commit is contained in:
jain
2023-08-23 11:16:46 +05:30
parent 5f3a9c35fa
commit 7068551050
4 changed files with 12 additions and 6 deletions

View File

@ -61,7 +61,8 @@ class CustomMiddleware(object):
response = custom_response(custom_error)
force_update = ForceUpdate.objects.filter(version=version, device_type=device_type).last()
api_endpoint_checks = not any(endpoint in api_endpoint for endpoint in ['/admin/', '/api/v1/admin/'])
if not force_update and api_endpoint_checks:
custom_error = custom_error_response(ERROR_CODE['2079'], response_status=status.HTTP_404_NOT_FOUND)
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)
return response