mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 01:55:21 +00:00
guardian code
This commit is contained in:
@ -74,7 +74,8 @@ ERROR_CODE = {
|
|||||||
"2041": "Article with given id doesn't exist.",
|
"2041": "Article with given id doesn't exist.",
|
||||||
"2042": "Article Card with given id doesn't exist.",
|
"2042": "Article Card with given id doesn't exist.",
|
||||||
"2043": "Article Survey with given id doesn't exist.",
|
"2043": "Article Survey with given id doesn't exist.",
|
||||||
"2044": "Task does not exist"
|
"2044": "Task does not exist",
|
||||||
|
"2045": "Invalid guardian"
|
||||||
}
|
}
|
||||||
"""Success message code"""
|
"""Success message code"""
|
||||||
SUCCESS_CODE = {
|
SUCCESS_CODE = {
|
||||||
|
@ -113,10 +113,12 @@ class JuniorListAPIView(viewsets.ModelViewSet):
|
|||||||
# requests.get('https://dev-api.zodqaapp.com/api/v1/top-junior/', headers=headers_token)
|
# requests.get('https://dev-api.zodqaapp.com/api/v1/top-junior/', headers=headers_token)
|
||||||
guardian_data = Guardian.objects.filter(user__email=request.user).last()
|
guardian_data = Guardian.objects.filter(user__email=request.user).last()
|
||||||
# fetch junior object
|
# fetch junior object
|
||||||
|
if guardian_data:
|
||||||
queryset = Junior.objects.filter(guardian_code__icontains=str(guardian_data.guardian_code))
|
queryset = Junior.objects.filter(guardian_code__icontains=str(guardian_data.guardian_code))
|
||||||
# use JuniorDetailListSerializer serializer
|
# use JuniorDetailListSerializer serializer
|
||||||
serializer = JuniorDetailListSerializer(queryset, many=True)
|
serializer = JuniorDetailListSerializer(queryset, many=True)
|
||||||
return custom_response(None, serializer.data, response_status=status.HTTP_200_OK)
|
return custom_response(None, serializer.data, response_status=status.HTTP_200_OK)
|
||||||
|
return custom_error_response(ERROR_CODE['2045'], response_status=status.HTTP_200_OK)
|
||||||
|
|
||||||
class AddJuniorAPIView(viewsets.ModelViewSet):
|
class AddJuniorAPIView(viewsets.ModelViewSet):
|
||||||
"""Add Junior by guardian"""
|
"""Add Junior by guardian"""
|
||||||
|
Reference in New Issue
Block a user