mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 00:24:54 +00:00
@ -93,7 +93,7 @@ def junior_account_update(user_tb):
|
||||
# Update junior account
|
||||
junior_data.is_active = False
|
||||
junior_data.is_verified = False
|
||||
junior_data.guardian_code = '{}'
|
||||
junior_data.guardian_code = None
|
||||
junior_data.guardian_code_status = str(NUMBER['one'])
|
||||
junior_data.is_deleted = True
|
||||
junior_data.save()
|
||||
|
||||
@ -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)
|
||||
@ -494,8 +499,6 @@ class ReAssignTaskSerializer(serializers.ModelSerializer):
|
||||
instance.save()
|
||||
return instance
|
||||
|
||||
|
||||
|
||||
class RemoveGuardianCodeSerializer(serializers.ModelSerializer):
|
||||
"""User task Serializer"""
|
||||
class Meta(object):
|
||||
|
||||
@ -62,5 +62,5 @@ urlpatterns = [
|
||||
path('api/v1/reassign-task/', ReAssignJuniorTaskAPIView.as_view()),
|
||||
path('api/v1/complete-article/', CompleteArticleAPIView.as_view()),
|
||||
path('api/v1/read-article-card/', ReadArticleCardAPIView.as_view()),
|
||||
path('api/v1/remove-guardian-code-request/', RemoveGuardianCodeAPIView.as_view()),
|
||||
path('api/v1/remove-guardian-code-request/', RemoveGuardianCodeAPIView.as_view())
|
||||
]
|
||||
|
||||
@ -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