mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
Merge pull request #261 from KiwiTechLLC/sprint5
article-list optimization
This commit is contained in:
@ -45,7 +45,11 @@ class CustomMiddleware(object):
|
||||
api_endpoint = request.path
|
||||
if request.user.is_authenticated:
|
||||
# device details
|
||||
device_details = UserDeviceDetails.objects.filter(user=request.user, device_id=device_id).last()
|
||||
if device_id:
|
||||
device_details = UserDeviceDetails.objects.filter(user=request.user, device_id=device_id).last()
|
||||
if not device_details and api_endpoint != '/api/v1/user/login/':
|
||||
custom_error = custom_error_response(ERROR_CODE['2037'], response_status=status.HTTP_404_NOT_FOUND)
|
||||
response = custom_response(custom_error)
|
||||
if user_type and str(user_type) == str(NUMBER['one']):
|
||||
junior = Junior.objects.filter(auth=request.user, is_active=False).last()
|
||||
if junior:
|
||||
@ -56,13 +60,11 @@ class CustomMiddleware(object):
|
||||
if guardian:
|
||||
custom_error = custom_error_response(ERROR_CODE['2075'], response_status=status.HTTP_404_NOT_FOUND)
|
||||
response = custom_response(custom_error)
|
||||
if device_id and not device_details and api_endpoint != '/api/v1/user/login/':
|
||||
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 version and device_type:
|
||||
custom_error = custom_error_response(ERROR_CODE['2079'],
|
||||
response_status=status.HTTP_308_PERMANENT_REDIRECT)
|
||||
response = custom_response(custom_error, status.HTTP_308_PERMANENT_REDIRECT)
|
||||
|
||||
if version and device_type:
|
||||
force_update = ForceUpdate.objects.filter(version=version, device_type=device_type).last()
|
||||
if not force_update:
|
||||
custom_error = custom_error_response(ERROR_CODE['2079'],
|
||||
response_status=status.HTTP_308_PERMANENT_REDIRECT)
|
||||
response = custom_response(custom_error, status.HTTP_308_PERMANENT_REDIRECT)
|
||||
return response
|
||||
|
Reference in New Issue
Block a user