mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
Merge pull request #320 from KiwiTechLLC/ZBKBCK-52
modified add junior api for exsiting junior.
This commit is contained in:
@ -103,9 +103,9 @@ ERROR_CODE = {
|
||||
"2074": "You can not complete this task because you does not exist in the system",
|
||||
# deactivate account
|
||||
"2075": "Your account is deactivated. Please contact with admin",
|
||||
"2076": "This junior already associate with you",
|
||||
"2076": "This junior already associated with you",
|
||||
"2077": "You can not add guardian",
|
||||
"2078": "This junior is not associate with you",
|
||||
"2078": "This junior is not associated with you",
|
||||
# force update
|
||||
"2079": "Please update your app version for enjoying uninterrupted services",
|
||||
"2080": "Can not add App version",
|
||||
|
@ -203,6 +203,16 @@ class AddJuniorAPIView(viewsets.ModelViewSet):
|
||||
"email":"abc@yopmail.com"
|
||||
}"""
|
||||
try:
|
||||
if user := User.objects.filter(username=request.data['email']).first():
|
||||
data = self.associate_guardian(user)
|
||||
if data == none:
|
||||
return custom_error_response(ERROR_CODE['2077'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
elif not data:
|
||||
return custom_error_response(ERROR_CODE['2076'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
elif data == "Max":
|
||||
return custom_error_response(ERROR_CODE['2081'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
return custom_response(SUCCESS_CODE['3021'], response_status=status.HTTP_200_OK)
|
||||
|
||||
info_data = {'user': request.user, 'relationship': str(request.data['relationship']),
|
||||
'email': request.data['email'], 'first_name': request.data['first_name'],
|
||||
'last_name': request.data['last_name'], 'image':None}
|
||||
@ -216,15 +226,7 @@ class AddJuniorAPIView(viewsets.ModelViewSet):
|
||||
# upload image on ali baba
|
||||
image_url = upload_image_to_alibaba(profile_image, filename)
|
||||
info_data.update({"image": image_url})
|
||||
if user := User.objects.filter(username=request.data['email']).first():
|
||||
data = self.associate_guardian(user)
|
||||
if data == none:
|
||||
return custom_error_response(ERROR_CODE['2077'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
elif not data:
|
||||
return custom_error_response(ERROR_CODE['2076'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
elif data == "Max":
|
||||
return custom_error_response(ERROR_CODE['2081'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
return custom_response(SUCCESS_CODE['3021'], response_status=status.HTTP_200_OK)
|
||||
|
||||
# use AddJuniorSerializer serializer
|
||||
serializer = AddJuniorSerializer(data=request.data, context=info_data)
|
||||
if serializer.is_valid():
|
||||
|
Reference in New Issue
Block a user