mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
Merge pull request #156 from KiwiTechLLC/sprint4
guardian list api changes
This commit is contained in:
@ -15,7 +15,8 @@ from account.utils import send_otp_email, generate_code
|
||||
from junior.models import Junior, JuniorPoints, JuniorGuardianRelationship
|
||||
from guardian.tasks import generate_otp
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from base.constants import PENDING, IN_PROGRESS, REJECTED, REQUESTED, COMPLETED, NUMBER, JUN, ZOD, EXPIRED
|
||||
from base.constants import (PENDING, IN_PROGRESS, REJECTED, REQUESTED, COMPLETED, NUMBER, JUN, ZOD, EXPIRED,
|
||||
GUARDIAN_CODE_STATUS)
|
||||
from guardian.models import Guardian, JuniorTask
|
||||
from account.models import UserEmailOtp, UserNotification
|
||||
from junior.utils import junior_notification_email, junior_approval_mail
|
||||
@ -283,7 +284,8 @@ class AddJuniorSerializer(serializers.ModelSerializer):
|
||||
junior_code=generate_code(JUN, user_data.id),
|
||||
referral_code=generate_code(ZOD, user_data.id),
|
||||
referral_code_used=guardian_data.referral_code,
|
||||
is_password_set=False, is_verified=True)
|
||||
is_password_set=False, is_verified=True,
|
||||
guardian_code_status=GUARDIAN_CODE_STATUS['2'])
|
||||
JuniorGuardianRelationship.objects.create(guardian=guardian_data, junior=junior_data,
|
||||
relationship=relationship)
|
||||
"""Generate otp"""
|
||||
@ -403,13 +405,15 @@ class AddGuardianSerializer(serializers.ModelSerializer):
|
||||
relationship = self.context['relationship']
|
||||
full_name = self.context['first_name'] + ' ' + self.context['last_name']
|
||||
junior_data = Junior.objects.filter(auth__username=junior).last()
|
||||
junior_data.guardian_code_status = GUARDIAN_CODE_STATUS['3']
|
||||
junior_data.save()
|
||||
instance = User.objects.filter(username=email).last()
|
||||
if instance:
|
||||
guardian_data = Guardian.objects.filter(user=instance).update(is_invited=True,
|
||||
referral_code=generate_code(ZOD,
|
||||
referral_code=generate_code(ZOD,
|
||||
instance.id),
|
||||
referral_code_used=junior_data.referral_code,
|
||||
is_verified=True)
|
||||
is_verified=True)
|
||||
UserNotification.objects.get_or_create(user=instance)
|
||||
return guardian_data
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user