mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
sonar issues
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
"""Views of Guardian"""
|
||||
|
||||
# django imports
|
||||
# Import IsAuthenticated
|
||||
# Import viewsets and status
|
||||
# Import PageNumberPagination
|
||||
# Import User
|
||||
# Import timezone
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework import viewsets, status
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
@ -18,7 +23,8 @@ from django.utils import timezone
|
||||
# from utils file
|
||||
# Import account's serializer
|
||||
# Import account's task
|
||||
|
||||
# Import notification constant
|
||||
# Import send_notification function
|
||||
from .serializers import (UserSerializer, CreateGuardianSerializer, TaskSerializer, TaskDetailsSerializer,
|
||||
TopJuniorSerializer, ApproveJuniorSerializer, ApproveTaskSerializer)
|
||||
from .models import Guardian, JuniorTask
|
||||
@ -58,12 +64,14 @@ class SignupViewset(viewsets.ModelViewSet):
|
||||
user = serializer.save()
|
||||
"""Generate otp"""
|
||||
otp = generate_otp()
|
||||
# expire otp after 1 day
|
||||
expiry = timezone.now() + timezone.timedelta(days=1)
|
||||
# create user email otp object
|
||||
UserEmailOtp.objects.create(email=request.data['email'], otp=otp,
|
||||
user_type=str(request.data['user_type']), expired_at=expiry)
|
||||
"""Send email to the register user"""
|
||||
send_otp_email(request.data['email'], otp)
|
||||
# send push notification for registration
|
||||
send_notification(REGISTRATION, None, user.id, {})
|
||||
return custom_response(SUCCESS_CODE['3001'],
|
||||
response_status=status.HTTP_200_OK)
|
||||
|
||||
Reference in New Issue
Block a user