mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
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",
|
"2074": "You can not complete this task because you does not exist in the system",
|
||||||
# deactivate account
|
# deactivate account
|
||||||
"2075": "Your account is deactivated. Please contact with admin",
|
"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",
|
"2077": "You can not add guardian",
|
||||||
"2078": "This junior is not associate with you",
|
"2078": "This junior is not associated with you",
|
||||||
# force update
|
# force update
|
||||||
"2079": "Please update your app version for enjoying uninterrupted services",
|
"2079": "Please update your app version for enjoying uninterrupted services",
|
||||||
"2080": "Can not add App version",
|
"2080": "Can not add App version",
|
||||||
|
@ -203,6 +203,16 @@ class AddJuniorAPIView(viewsets.ModelViewSet):
|
|||||||
"email":"abc@yopmail.com"
|
"email":"abc@yopmail.com"
|
||||||
}"""
|
}"""
|
||||||
try:
|
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']),
|
info_data = {'user': request.user, 'relationship': str(request.data['relationship']),
|
||||||
'email': request.data['email'], 'first_name': request.data['first_name'],
|
'email': request.data['email'], 'first_name': request.data['first_name'],
|
||||||
'last_name': request.data['last_name'], 'image':None}
|
'last_name': request.data['last_name'], 'image':None}
|
||||||
@ -216,15 +226,7 @@ class AddJuniorAPIView(viewsets.ModelViewSet):
|
|||||||
# upload image on ali baba
|
# upload image on ali baba
|
||||||
image_url = upload_image_to_alibaba(profile_image, filename)
|
image_url = upload_image_to_alibaba(profile_image, filename)
|
||||||
info_data.update({"image": image_url})
|
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
|
# use AddJuniorSerializer serializer
|
||||||
serializer = AddJuniorSerializer(data=request.data, context=info_data)
|
serializer = AddJuniorSerializer(data=request.data, context=info_data)
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
|
Reference in New Issue
Block a user