Merge pull request #238 from KiwiTechLLC/dev

Dev
This commit is contained in:
Abu Talib
2023-08-21 19:24:51 +05:30
committed by GitHub
7 changed files with 45 additions and 15 deletions

View File

@ -308,7 +308,7 @@ class EmailVerificationSerializer(serializers.ModelSerializer):
class Meta(object): class Meta(object):
"""Meta info""" """Meta info"""
model = UserEmailOtp model = UserEmailOtp
fields = '__all__' fields = ('email',)

View File

@ -39,8 +39,6 @@ router.register('user', UserLogin, basename='user')
router.register('admin', AdminLoginViewSet, basename='admin') router.register('admin', AdminLoginViewSet, basename='admin')
"""google login end point""" """google login end point"""
router.register('google-login', GoogleLoginViewSet, basename='admin') router.register('google-login', GoogleLoginViewSet, basename='admin')
router.register('send-phone-otp', SendPhoneOtp, basename='send-phone-otp')
router.register('user-phone-verification', UserPhoneVerification, basename='user-phone-verification')
"""email verification end point""" """email verification end point"""
router.register('user-email-verification', UserEmailVerification, basename='user-email-verification') router.register('user-email-verification', UserEmailVerification, basename='user-email-verification')
"""Resend email otp end point""" """Resend email otp end point"""

View File

@ -204,7 +204,7 @@ def custom_error_response(detail, response_status):
if not detail: if not detail:
"""when details is empty""" """when details is empty"""
detail = {} detail = {}
return Response({"error": detail, "status": "failed", "code": response_status}) return Response({"error": detail, "status": "failed", "code": response_status}, status=status.HTTP_400_BAD_REQUEST)
def get_user_data(attrs): def get_user_data(attrs):

View File

@ -467,8 +467,11 @@ class ReSendEmailOtp(viewsets.ModelViewSet):
"""Send otp on phone""" """Send otp on phone"""
serializer_class = EmailVerificationSerializer serializer_class = EmailVerificationSerializer
permission_classes = [IsAuthenticated] permission_classes = [IsAuthenticated]
http_method_names = ('post',)
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
"""Param
{"email":"ashok@yopmail.com"}
"""
otp = generate_otp() otp = generate_otp()
if User.objects.filter(email=request.data['email']): if User.objects.filter(email=request.data['email']):
expiry = timezone.now() + timezone.timedelta(days=1) expiry = timezone.now() + timezone.timedelta(days=1)
@ -489,6 +492,7 @@ class ProfileAPIViewSet(viewsets.ModelViewSet):
"""Profile viewset""" """Profile viewset"""
serializer_class = JuniorProfileSerializer serializer_class = JuniorProfileSerializer
permission_classes = [IsAuthenticated] permission_classes = [IsAuthenticated]
http_method_names = ('get',)
def list(self, request, *args, **kwargs): def list(self, request, *args, **kwargs):
"""profile view""" """profile view"""

View File

@ -1,7 +1,7 @@
""" Urls files""" """ Urls files"""
"""Django import""" """Django import"""
from django.urls import path, include from django.urls import path, include
from .views import (SignupViewset, UpdateGuardianProfile, AllTaskListAPIView, CreateTaskAPIView, TaskListAPIView, from .views import (SignupViewset, UpdateGuardianProfile, CreateTaskAPIView, TaskListAPIView,
SearchTaskListAPIView, TopJuniorListAPIView, ApproveJuniorAPIView, ApproveTaskAPIView, SearchTaskListAPIView, TopJuniorListAPIView, ApproveJuniorAPIView, ApproveTaskAPIView,
GuardianListAPIView) GuardianListAPIView)
"""Third party import""" """Third party import"""
@ -25,8 +25,6 @@ router.register('sign-up', SignupViewset, basename='sign-up')
router.register('create-guardian-profile', UpdateGuardianProfile, basename='update-guardian-profile') router.register('create-guardian-profile', UpdateGuardianProfile, basename='update-guardian-profile')
# Create Task API""" # Create Task API"""
router.register('create-task', CreateTaskAPIView, basename='create-task') router.register('create-task', CreateTaskAPIView, basename='create-task')
# All Task list API"""
router.register('all-task-list', AllTaskListAPIView, basename='all-task-list')
# Task list bases on the status API""" # Task list bases on the status API"""
router.register('task-list', TaskListAPIView, basename='task-list') router.register('task-list', TaskListAPIView, basename='task-list')
# Leaderboard API""" # Leaderboard API"""

View File

@ -57,6 +57,7 @@ class SignupViewset(viewsets.ModelViewSet):
"""Signup view set""" """Signup view set"""
queryset = User.objects.all() queryset = User.objects.all()
serializer_class = UserSerializer serializer_class = UserSerializer
http_method_names = ('post',)
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
"""Create user profile""" """Create user profile"""
device_id = request.META.get('HTTP_DEVICE_ID') device_id = request.META.get('HTTP_DEVICE_ID')
@ -209,6 +210,7 @@ class SearchTaskListAPIView(viewsets.ModelViewSet):
serializer_class = TaskDetailsSerializer serializer_class = TaskDetailsSerializer
permission_classes = [IsAuthenticated] permission_classes = [IsAuthenticated]
pagination_class = PageNumberPagination pagination_class = PageNumberPagination
http_method_names = ('get',)
def get_queryset(self): def get_queryset(self):
"""Get the queryset for the view""" """Get the queryset for the view"""
@ -335,7 +337,7 @@ class ApproveTaskAPIView(viewsets.ModelViewSet):
serializer.save() serializer.save()
return custom_response(SUCCESS_CODE['3026'], response_status=status.HTTP_200_OK) return custom_response(SUCCESS_CODE['3026'], response_status=status.HTTP_200_OK)
else: else:
return custom_response(ERROR_CODE['2038'], response_status=status.HTTP_400_BAD_REQUEST) return custom_error_response(ERROR_CODE['2038'], response_status=status.HTTP_400_BAD_REQUEST)
except Exception as e: except Exception as e:
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)

View File

@ -13,7 +13,9 @@ import requests
from rest_framework.viewsets import GenericViewSet, mixins from rest_framework.viewsets import GenericViewSet, mixins
"""Django app import""" """Django app import"""
from drf_yasg.utils import swagger_auto_schema
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
# Import guardian's model, # Import guardian's model,
# Import junior's model, # Import junior's model,
# Import account's model, # Import account's model,
@ -99,7 +101,7 @@ class UpdateJuniorProfile(viewsets.ModelViewSet):
except Exception as e: except Exception as e:
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 ValidateGuardianCode(viewsets.ViewSet): class ValidateGuardianCode(viewsets.ModelViewSet):
"""Check guardian code exist or not""" """Check guardian code exist or not"""
permission_classes = [IsAuthenticated] permission_classes = [IsAuthenticated]
@ -156,7 +158,14 @@ class AddJuniorAPIView(viewsets.ModelViewSet):
http_method_names = ('post',) http_method_names = ('post',)
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
""" junior list""" """ add junior
{ "gender":"1",
"first_name":"abc",
"last_name":"xyz",
"dob":"2023-12-12",
"relationship":"2",
"email":"abc@yopmail.com"
}"""
try: try:
info_data = {'user': request.user, 'relationship': str(request.data['relationship']), info_data = {'user': request.user, 'relationship': str(request.data['relationship']),
'email': request.data['email'], 'first_name': request.data['first_name'], 'email': request.data['email'], 'first_name': request.data['first_name'],
@ -235,12 +244,25 @@ class InvitedJuniorAPIView(viewsets.ModelViewSet):
class FilterJuniorAPIView(viewsets.ModelViewSet): class FilterJuniorAPIView(viewsets.ModelViewSet):
"""Update guardian profile""" """filter junior profile"""
serializer_class = JuniorDetailListSerializer serializer_class = JuniorDetailListSerializer
permission_classes = [IsAuthenticated] permission_classes = [IsAuthenticated]
pagination_class = PageNumberPagination pagination_class = PageNumberPagination
http_method_names = ('get',) http_method_names = ('get',)
@swagger_auto_schema(
manual_parameters=[
# Example of a query parameter
openapi.Parameter(
'title', # Query parameter name
openapi.IN_QUERY, # Parameter location
description='title of the name',
type=openapi.TYPE_STRING, # Parameter type
),
# Add more parameters as needed
]
)
def get_queryset(self): def get_queryset(self):
"""Get the queryset for the view""" """Get the queryset for the view"""
title = self.request.GET.get('title') title = self.request.GET.get('title')
@ -386,7 +408,7 @@ class JuniorPointsListAPIView(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 ValidateReferralCode(viewsets.ViewSet): class ValidateReferralCode(viewsets.ModelViewSet):
"""Check guardian code exist or not""" """Check guardian code exist or not"""
permission_classes = [IsAuthenticated] permission_classes = [IsAuthenticated]
http_method_names = ('get',) http_method_names = ('get',)
@ -421,7 +443,13 @@ class InviteGuardianAPIView(viewsets.ModelViewSet):
permission_classes = [IsAuthenticated] permission_classes = [IsAuthenticated]
http_method_names = ('post',) http_method_names = ('post',)
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
""" junior list""" """ add guardian
{
"first_name":"abc",
"last_name":"xyz",
"email":"abc@yopmail.com",
"relationship":2
}"""
try: try:
if request.data['email'] == '': if request.data['email'] == '':
return custom_error_response(ERROR_CODE['2062'], response_status=status.HTTP_400_BAD_REQUEST) return custom_error_response(ERROR_CODE['2062'], response_status=status.HTTP_400_BAD_REQUEST)