force update

This commit is contained in:
jain
2023-08-22 18:29:22 +05:30
parent f8e529600b
commit 05fd76a50b
10 changed files with 65 additions and 12 deletions

View File

@ -41,6 +41,7 @@ class CustomMiddleware(object):
user_type = request.META.get('HTTP_USER_TYPE')
version = request.META.get('HTTP_VERSION')
device_type = str(request.META.get('HTTP_TYPE'))
api_endpoint = request.path
if request.user.is_authenticated:
# device details
@ -59,5 +60,8 @@ class CustomMiddleware(object):
custom_error = custom_error_response(ERROR_CODE['2037'], response_status=status.HTTP_404_NOT_FOUND)
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)
response = custom_response(custom_error)
return response