mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
add three guardian at a time
This commit is contained in:
@ -106,7 +106,8 @@ ERROR_CODE = {
|
||||
"2077": "You can not add guardian",
|
||||
"2078": "This junior is not associate with you",
|
||||
"2079": "Please update your app version for enjoying uninterrupted services",
|
||||
"2080": "Can not add App version"
|
||||
"2080": "Can not add App version",
|
||||
"2081": "You can not add more than 3 guardian"
|
||||
|
||||
}
|
||||
"""Success message code"""
|
||||
|
@ -88,11 +88,16 @@ class CreateJuniorSerializer(serializers.ModelSerializer):
|
||||
if junior:
|
||||
"""update details according to the data get from request"""
|
||||
junior.gender = validated_data.get('gender',junior.gender)
|
||||
"""Update guardian code"""
|
||||
junior.guardian_code = validated_data.get('guardian_code', junior.guardian_code)
|
||||
"""condition for guardian code"""
|
||||
# Update guardian code"""
|
||||
# condition for guardian code
|
||||
if guardian_code:
|
||||
junior.guardian_code = guardian_code
|
||||
if not junior.guardian_code:
|
||||
junior.guardian_code = []
|
||||
junior.guardian_code.extend(guardian_code)
|
||||
elif len(junior.guardian_code) < 3 and len(guardian_code) < 3:
|
||||
junior.guardian_code.extend(guardian_code)
|
||||
else:
|
||||
raise serializers.ValidationError({"error":ERROR_CODE['2081'],"code":"400", "status":"failed"})
|
||||
guardian_data = Guardian.objects.filter(guardian_code=guardian_code[0]).last()
|
||||
if guardian_data:
|
||||
JuniorGuardianRelationship.objects.get_or_create(guardian=guardian_data, junior=junior)
|
||||
|
@ -99,7 +99,8 @@ class UpdateJuniorProfile(viewsets.ModelViewSet):
|
||||
return custom_response(None, serializer.data, response_status=status.HTTP_200_OK)
|
||||
return custom_error_response(serializer.errors, response_status=status.HTTP_400_BAD_REQUEST)
|
||||
except Exception as e:
|
||||
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
||||
error_detail = e.detail.get('error', None)
|
||||
return custom_error_response(error_detail, response_status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
class ValidateGuardianCode(viewsets.ModelViewSet):
|
||||
"""Check guardian code exist or not"""
|
||||
|
Reference in New Issue
Block a user