mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 13:49:40 +00:00
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,
|
||||
InviteGuardianAPIView, StartTaskAPIView, ReAssignJuniorTaskAPIView, StartArticleAPIView,
|
||||
StartAssessmentAPIView, CheckAnswerAPIView, CompleteArticleAPIView, ReadArticleCardAPIView,
|
||||
CreateArticleCardAPIView, RemoveGuardianCodeAPIView, FAQViewSet)
|
||||
CreateArticleCardAPIView, RemoveGuardianCodeAPIView, FAQViewSet, CheckJuniorApiViewSet)
|
||||
"""Third party import"""
|
||||
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')
|
||||
# junior list API"""
|
||||
router.register('junior-list', JuniorListAPIView, basename='junior-list')
|
||||
|
||||
router.register('check-junior', CheckJuniorApiViewSet, basename='check-junior')
|
||||
# Add junior list API"""
|
||||
router.register('add-junior', AddJuniorAPIView, basename='add-junior')
|
||||
# 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)
|
||||
|
||||
|
||||
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):
|
||||
"""Add Junior by guardian"""
|
||||
serializer_class = AddJuniorSerializer
|
||||
|
Reference in New Issue
Block a user