mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
jira-7 email
This commit is contained in:
@ -8,7 +8,7 @@ from django.db import transaction
|
||||
from django.contrib.auth.models import User
|
||||
"""Import Django app"""
|
||||
from .models import Guardian
|
||||
from account.models import UserProfile
|
||||
from account.models import UserProfile, UserEmailOtp
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from .utils import upload_image_to_alibaba
|
||||
from junior.models import Junior
|
||||
@ -43,13 +43,12 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
except Exception as e:
|
||||
"""Error handling"""
|
||||
logging.error(e)
|
||||
raise serializers.ValidationError({"details":ERROR_CODE['2021']})
|
||||
|
||||
def save(self, **kwargs):
|
||||
"""save the data"""
|
||||
with transaction.atomic():
|
||||
instance = super().save(**kwargs)
|
||||
return instance
|
||||
otp = UserEmailOtp.objects.filter(email=email).last()
|
||||
otp_verified = False
|
||||
if otp and otp.is_verified:
|
||||
otp_verified = True
|
||||
raise serializers.ValidationError({"details":ERROR_CODE['2021'], "otp_verified":otp_verified, "code": "400", "status":"failed",
|
||||
})
|
||||
|
||||
class CreateGuardianSerializer(serializers.ModelSerializer):
|
||||
"""Create guardian serializer"""
|
||||
@ -86,7 +85,7 @@ class CreateGuardianSerializer(serializers.ModelSerializer):
|
||||
|
||||
def create(self, validated_data):
|
||||
"""Create guardian profile"""
|
||||
phone_number = validated_data.pop('phone', None)
|
||||
phone_number = validated_data.get('phone', None)
|
||||
guardian_data = Guardian.objects.filter(phone=phone_number)
|
||||
junior_data = Junior.objects.filter(phone=phone_number)
|
||||
if phone_number and (guardian_data or junior_data):
|
||||
|
Reference in New Issue
Block a user