mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-14 17:45:46 +00:00
sonar issue
This commit is contained in:
@ -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
|
||||
|
@ -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"
|
||||
|
@ -58,8 +58,10 @@ ERROR_CODE = {
|
||||
"2032": "Failed to send email",
|
||||
"2033": "Missing required fields",
|
||||
"2034": "Junior is not associated",
|
||||
# image size
|
||||
"2035": "Image should not be 0 kb",
|
||||
"2036": "Choose valid user",
|
||||
# log in multiple device msg
|
||||
"2037": "You are already log in another device"
|
||||
}
|
||||
"""Success message code"""
|
||||
|
@ -9,15 +9,15 @@ from rest_framework import routers
|
||||
"""Define Router"""
|
||||
router = routers.SimpleRouter()
|
||||
|
||||
"""API End points with router
|
||||
in this file
|
||||
we define various api end point
|
||||
that is covered in this guardian
|
||||
section API:- like
|
||||
sign-up, create guardian profile,
|
||||
create-task,
|
||||
all task list, top junior,
|
||||
filter-task"""
|
||||
# API End points with router
|
||||
# in this file
|
||||
# we define various api end point
|
||||
# that is covered in this guardian
|
||||
# section API:- like
|
||||
# sign-up, create guardian profile,
|
||||
# create-task,
|
||||
# all task list, top junior,
|
||||
# filter-task"""
|
||||
"""Sign up API"""
|
||||
router.register('sign-up', SignupViewset, basename='sign-up')
|
||||
"""Create guardian profile API"""
|
||||
|
Reference in New Issue
Block a user