mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 01:55:21 +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']
|
list_display = ['user', 'push_notification', 'email_notification', 'sms_notification']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
"""Return image url"""
|
||||||
return self.image_url
|
return self.image_url
|
||||||
@admin.register(DefaultTaskImages)
|
@admin.register(DefaultTaskImages)
|
||||||
class DefaultTaskImagesAdmin(admin.ModelAdmin):
|
class DefaultTaskImagesAdmin(admin.ModelAdmin):
|
||||||
@ -26,6 +27,7 @@ class DefaultTaskImagesAdmin(admin.ModelAdmin):
|
|||||||
list_display = ['task_name', 'image_url']
|
list_display = ['task_name', 'image_url']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
"""Return image url"""
|
||||||
return self.image_url
|
return self.image_url
|
||||||
|
|
||||||
@admin.register(UserEmailOtp)
|
@admin.register(UserEmailOtp)
|
||||||
@ -43,4 +45,5 @@ class UserDeviceDetailsAdmin(admin.ModelAdmin):
|
|||||||
list_display = ['user', 'device_id']
|
list_display = ['user', 'device_id']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
"""Return user email"""
|
||||||
return self.user.email
|
return self.user.email
|
||||||
|
@ -8,10 +8,10 @@ from account.utils import custom_error_response
|
|||||||
from account.models import UserDeviceDetails
|
from account.models import UserDeviceDetails
|
||||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||||
|
|
||||||
"""Custom middleware
|
"""Custom middleware
|
||||||
when user login with
|
when user login with
|
||||||
multiple device simultaneously"""
|
multiple device simultaneously"""
|
||||||
class CustomMiddleware:
|
class CustomMiddleware(object):
|
||||||
"""Custom middleware"""
|
"""Custom middleware"""
|
||||||
def __init__(self, get_response):
|
def __init__(self, get_response):
|
||||||
"""response"""
|
"""response"""
|
||||||
@ -21,11 +21,11 @@ class CustomMiddleware:
|
|||||||
# Code to be executed before the view is called
|
# Code to be executed before the view is called
|
||||||
response = self.get_response(request)
|
response = self.get_response(request)
|
||||||
# Code to be executed after the view is called
|
# 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:
|
if request.user.is_authenticated:
|
||||||
"""device details"""
|
"""device details"""
|
||||||
device_details = UserDeviceDetails.objects.filter(user=request.user, device_id=device_id).last()
|
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)
|
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)
|
response = Response(custom_error.data, status=status.HTTP_404_NOT_FOUND)
|
||||||
# Set content type header to "application/json"
|
# Set content type header to "application/json"
|
||||||
|
@ -58,8 +58,10 @@ ERROR_CODE = {
|
|||||||
"2032": "Failed to send email",
|
"2032": "Failed to send email",
|
||||||
"2033": "Missing required fields",
|
"2033": "Missing required fields",
|
||||||
"2034": "Junior is not associated",
|
"2034": "Junior is not associated",
|
||||||
|
# image size
|
||||||
"2035": "Image should not be 0 kb",
|
"2035": "Image should not be 0 kb",
|
||||||
"2036": "Choose valid user",
|
"2036": "Choose valid user",
|
||||||
|
# log in multiple device msg
|
||||||
"2037": "You are already log in another device"
|
"2037": "You are already log in another device"
|
||||||
}
|
}
|
||||||
"""Success message code"""
|
"""Success message code"""
|
||||||
|
@ -9,15 +9,15 @@ from rest_framework import routers
|
|||||||
"""Define Router"""
|
"""Define Router"""
|
||||||
router = routers.SimpleRouter()
|
router = routers.SimpleRouter()
|
||||||
|
|
||||||
"""API End points with router
|
# API End points with router
|
||||||
in this file
|
# in this file
|
||||||
we define various api end point
|
# we define various api end point
|
||||||
that is covered in this guardian
|
# that is covered in this guardian
|
||||||
section API:- like
|
# section API:- like
|
||||||
sign-up, create guardian profile,
|
# sign-up, create guardian profile,
|
||||||
create-task,
|
# create-task,
|
||||||
all task list, top junior,
|
# all task list, top junior,
|
||||||
filter-task"""
|
# filter-task"""
|
||||||
"""Sign up API"""
|
"""Sign up API"""
|
||||||
router.register('sign-up', SignupViewset, basename='sign-up')
|
router.register('sign-up', SignupViewset, basename='sign-up')
|
||||||
"""Create guardian profile API"""
|
"""Create guardian profile API"""
|
||||||
|
Reference in New Issue
Block a user