mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 10:26:16 +00:00
sonar issues fixed
This commit is contained in:
@ -1,10 +1,20 @@
|
||||
"""Account serializer"""
|
||||
"""Django Imoprt"""
|
||||
"""Django Import"""
|
||||
import random
|
||||
from rest_framework import serializers
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework_simplejwt.tokens import RefreshToken
|
||||
"""App import"""
|
||||
# Import guardian's model,
|
||||
# Import junior's model,
|
||||
# Import account's model,
|
||||
# Import constant from
|
||||
# base package,
|
||||
# Import messages from
|
||||
# base package,
|
||||
# Import some functions
|
||||
# from utils file"""
|
||||
|
||||
from guardian.models import Guardian
|
||||
from junior.models import Junior
|
||||
from account.models import UserEmailOtp, DefaultTaskImages, UserDelete, UserNotification, UserPhoneOtp
|
||||
@ -12,6 +22,25 @@ from base.constants import GUARDIAN, JUNIOR, SUPERUSER
|
||||
from base.messages import ERROR_CODE_REQUIRED, ERROR_CODE, SUCCESS_CODE, STATUS_CODE_ERROR
|
||||
from .utils import delete_user_account_condition_social, delete_user_account_condition
|
||||
|
||||
# In this serializer file
|
||||
# define google login serializer
|
||||
# update junior profile,
|
||||
# update guardian profile,
|
||||
# super admin serializer,
|
||||
# reset password,
|
||||
# forgot password,
|
||||
# change password,
|
||||
# basic junior serializer,
|
||||
# basic guardian serializer,
|
||||
# user delete account serializer,
|
||||
# user notification serializer,
|
||||
# update user notification serializer,
|
||||
# default task's images serializer,
|
||||
# upload default task's images serializer,
|
||||
# email verification serializer,
|
||||
# phone otp serializer
|
||||
|
||||
|
||||
class GoogleLoginSerializer(serializers.Serializer):
|
||||
"""google login serializer"""
|
||||
access_token = serializers.CharField(max_length=5000, required=True)
|
||||
@ -89,6 +118,7 @@ class ChangePasswordSerializer(serializers.Serializer):
|
||||
def create(self, validated_data):
|
||||
new_password = validated_data.pop('new_password')
|
||||
current_password = validated_data.pop('current_password')
|
||||
"""Check new password is different from current password"""
|
||||
if new_password == current_password:
|
||||
raise serializers.ValidationError({"details": ERROR_CODE['2026']})
|
||||
user_details = User.objects.filter(email=self.context).last()
|
||||
|
Reference in New Issue
Block a user