mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
referral code
This commit is contained in:
@ -27,7 +27,8 @@ from rest_framework_simplejwt.tokens import RefreshToken
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from base.constants import NUMBER
|
||||
from guardian.tasks import generate_otp
|
||||
from account.utils import send_otp_email, send_support_email, custom_response, custom_error_response
|
||||
from account.utils import (send_otp_email, send_support_email, custom_response, custom_error_response,
|
||||
generate_alphanumeric_code)
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from templated_email import send_templated_mail
|
||||
import google.oauth2.credentials
|
||||
@ -89,19 +90,15 @@ class GoogleLoginMixin:
|
||||
if str(user_type) == '1':
|
||||
junior_query = Junior.objects.create(auth=user_obj, is_verified=True, is_active=True,
|
||||
image=profile_picture, signup_method='2',
|
||||
junior_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)]),
|
||||
referral_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)])
|
||||
junior_code=generate_alphanumeric_code(6),
|
||||
referral_code=generate_alphanumeric_code(6)
|
||||
)
|
||||
serializer = JuniorSerializer(junior_query)
|
||||
if str(user_type) == '2':
|
||||
guardian_query = Guardian.objects.create(user=user_obj, is_verified=True, is_active=True,
|
||||
image=profile_picture,signup_method='2',
|
||||
guardian_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)]),
|
||||
referral_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)])
|
||||
guardian_code=generate_alphanumeric_code(6),
|
||||
referral_code=generate_alphanumeric_code(6)
|
||||
)
|
||||
serializer = GuardianSerializer(guardian_query)
|
||||
# Return a JSON response with the user's email and name
|
||||
@ -143,18 +140,15 @@ class SigninWithApple(views.APIView):
|
||||
user = User.objects.create(**user_data)
|
||||
if str(user_type) == '1':
|
||||
junior_query = Junior.objects.create(auth=user, is_verified=True, is_active=True,
|
||||
signup_method='3',junior_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)]),
|
||||
referral_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)]))
|
||||
signup_method='3',
|
||||
junior_code=generate_alphanumeric_code(6),
|
||||
referral_code=generate_alphanumeric_code(6))
|
||||
serializer = JuniorSerializer(junior_query)
|
||||
if str(user_type) == '2':
|
||||
guardian_query = Guardian.objects.create(user=user, is_verified=True, is_active=True,
|
||||
signup_method='3',
|
||||
guardian_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)]),
|
||||
referral_code=''.join(
|
||||
[str(random.randrange(9)) for _ in range(6)]))
|
||||
guardian_code=generate_alphanumeric_code(6),
|
||||
referral_code=generate_alphanumeric_code(6))
|
||||
serializer = GuardianSerializer(guardian_query)
|
||||
return custom_response(SUCCESS_CODE['3003'], serializer.data,
|
||||
response_status=status.HTTP_200_OK)
|
||||
@ -169,7 +163,7 @@ class UpdateProfileImage(views.APIView):
|
||||
def put(self, request, format=None):
|
||||
try:
|
||||
image = request.data['image']
|
||||
if image.size == NUMBER['zero']:
|
||||
if image and image.size == NUMBER['zero']:
|
||||
return custom_error_response(ERROR_CODE['2035'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
filename = f"images/{image.name}"
|
||||
image_url = upload_image_to_alibaba(image, filename)
|
||||
|
Reference in New Issue
Block a user