mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
Merge pull request #319 from KiwiTechLLC/ZBKBCK-52
api to check whether given user exist or not
This commit is contained in:
@ -6,7 +6,7 @@ from .views import (UpdateJuniorProfile, ValidateGuardianCode, JuniorListAPIView
|
|||||||
CompleteJuniorTaskAPIView, JuniorPointsListAPIView, ValidateReferralCode,
|
CompleteJuniorTaskAPIView, JuniorPointsListAPIView, ValidateReferralCode,
|
||||||
InviteGuardianAPIView, StartTaskAPIView, ReAssignJuniorTaskAPIView, StartArticleAPIView,
|
InviteGuardianAPIView, StartTaskAPIView, ReAssignJuniorTaskAPIView, StartArticleAPIView,
|
||||||
StartAssessmentAPIView, CheckAnswerAPIView, CompleteArticleAPIView, ReadArticleCardAPIView,
|
StartAssessmentAPIView, CheckAnswerAPIView, CompleteArticleAPIView, ReadArticleCardAPIView,
|
||||||
CreateArticleCardAPIView, RemoveGuardianCodeAPIView, FAQViewSet)
|
CreateArticleCardAPIView, RemoveGuardianCodeAPIView, FAQViewSet, CheckJuniorApiViewSet)
|
||||||
"""Third party import"""
|
"""Third party import"""
|
||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
|
|
||||||
@ -29,6 +29,8 @@ router.register('create-junior-profile', UpdateJuniorProfile, basename='profile-
|
|||||||
router.register('validate-guardian-code', ValidateGuardianCode, basename='validate-guardian-code')
|
router.register('validate-guardian-code', ValidateGuardianCode, basename='validate-guardian-code')
|
||||||
# junior list API"""
|
# junior list API"""
|
||||||
router.register('junior-list', JuniorListAPIView, basename='junior-list')
|
router.register('junior-list', JuniorListAPIView, basename='junior-list')
|
||||||
|
|
||||||
|
router.register('check-junior', CheckJuniorApiViewSet, basename='check-junior')
|
||||||
# Add junior list API"""
|
# Add junior list API"""
|
||||||
router.register('add-junior', AddJuniorAPIView, basename='add-junior')
|
router.register('add-junior', AddJuniorAPIView, basename='add-junior')
|
||||||
# Invited junior list API"""
|
# Invited junior list API"""
|
||||||
|
|||||||
@ -164,6 +164,29 @@ class JuniorListAPIView(viewsets.ModelViewSet):
|
|||||||
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
class CheckJuniorApiViewSet(viewsets.GenericViewSet):
|
||||||
|
"""
|
||||||
|
api to check whether given user exist or not
|
||||||
|
"""
|
||||||
|
serializer_class = None
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
junior = Junior.objects.filter(auth__email=self.request.data.get('email')).first()
|
||||||
|
return junior
|
||||||
|
|
||||||
|
def create(self, request, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
:param request:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
junior = self.get_queryset()
|
||||||
|
data = {
|
||||||
|
'junior_exist': True if junior else False
|
||||||
|
}
|
||||||
|
return custom_response(None, data)
|
||||||
|
|
||||||
|
|
||||||
class AddJuniorAPIView(viewsets.ModelViewSet):
|
class AddJuniorAPIView(viewsets.ModelViewSet):
|
||||||
"""Add Junior by guardian"""
|
"""Add Junior by guardian"""
|
||||||
serializer_class = AddJuniorSerializer
|
serializer_class = AddJuniorSerializer
|
||||||
|
|||||||
Reference in New Issue
Block a user