sonar issue

This commit is contained in:
jain
2023-07-15 23:07:12 +05:30
parent 5bd865a685
commit 32e52e17f4
4 changed files with 19 additions and 14 deletions

View File

@ -19,6 +19,7 @@ class UserNotificationAdmin(admin.ModelAdmin):
list_display = ['user', 'push_notification', 'email_notification', 'sms_notification']
def __str__(self):
"""Return image url"""
return self.image_url
@admin.register(DefaultTaskImages)
class DefaultTaskImagesAdmin(admin.ModelAdmin):
@ -26,6 +27,7 @@ class DefaultTaskImagesAdmin(admin.ModelAdmin):
list_display = ['task_name', 'image_url']
def __str__(self):
"""Return image url"""
return self.image_url
@admin.register(UserEmailOtp)
@ -43,4 +45,5 @@ class UserDeviceDetailsAdmin(admin.ModelAdmin):
list_display = ['user', 'device_id']
def __str__(self):
"""Return user email"""
return self.user.email

View File

@ -8,10 +8,10 @@ from account.utils import custom_error_response
from account.models import UserDeviceDetails
from base.messages import ERROR_CODE, SUCCESS_CODE
"""Custom middleware
when user login with
"""Custom middleware
when user login with
multiple device simultaneously"""
class CustomMiddleware:
class CustomMiddleware(object):
"""Custom middleware"""
def __init__(self, get_response):
"""response"""
@ -21,11 +21,11 @@ class CustomMiddleware:
# Code to be executed before the view is called
response = self.get_response(request)
# Code to be executed after the view is called
device_id = request.META['HTTP_DEVICE_ID']
device_id = request.META.get('HTTP_DEVICE_ID')
if request.user.is_authenticated:
"""device details"""
device_details = UserDeviceDetails.objects.filter(user=request.user, device_id=device_id).last()
if not device_details:
if device_id and not device_details:
custom_error = custom_error_response(ERROR_CODE['2037'], response_status=status.HTTP_404_NOT_FOUND)
response = Response(custom_error.data, status=status.HTTP_404_NOT_FOUND)
# Set content type header to "application/json"