mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 18:36:18 +00:00
changes in requirement file
This commit is contained in:
@ -169,7 +169,6 @@ class JuniorSerializer(serializers.ModelSerializer):
|
|||||||
auth_token = serializers.SerializerMethodField('get_auth_token')
|
auth_token = serializers.SerializerMethodField('get_auth_token')
|
||||||
|
|
||||||
def get_auth_token(self, obj):
|
def get_auth_token(self, obj):
|
||||||
print("obj===>",obj,'===>',type(obj))
|
|
||||||
refresh = RefreshToken.for_user(obj.auth)
|
refresh = RefreshToken.for_user(obj.auth)
|
||||||
access_token = str(refresh.access_token)
|
access_token = str(refresh.access_token)
|
||||||
return access_token
|
return access_token
|
||||||
|
@ -186,7 +186,6 @@ class ForgotPasswordAPIView(views.APIView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
expiry = datetime.today() + timedelta(days=1)
|
expiry = datetime.today() + timedelta(days=1)
|
||||||
print("expiry===>", expiry, '===>', type(expiry))
|
|
||||||
user_data, created = UserEmailOtp.objects.get_or_create(email=email)
|
user_data, created = UserEmailOtp.objects.get_or_create(email=email)
|
||||||
if created:
|
if created:
|
||||||
user_data.expired_at = expiry
|
user_data.expired_at = expiry
|
||||||
@ -255,7 +254,6 @@ class UserLogin(viewsets.ViewSet):
|
|||||||
email_verified = UserEmailOtp.objects.filter(email=username).last()
|
email_verified = UserEmailOtp.objects.filter(email=username).last()
|
||||||
refresh = RefreshToken.for_user(user)
|
refresh = RefreshToken.for_user(user)
|
||||||
access_token = str(refresh.access_token)
|
access_token = str(refresh.access_token)
|
||||||
print("email_verified.user_type==>",email_verified.user_type)
|
|
||||||
data = {"auth_token":access_token, "is_profile_complete": False,
|
data = {"auth_token":access_token, "is_profile_complete": False,
|
||||||
"user_type": email_verified.user_type,
|
"user_type": email_verified.user_type,
|
||||||
}
|
}
|
||||||
@ -339,7 +337,6 @@ class ReSendEmailOtp(viewsets.ModelViewSet):
|
|||||||
otp = generate_otp()
|
otp = generate_otp()
|
||||||
if User.objects.filter(email=request.data['email']):
|
if User.objects.filter(email=request.data['email']):
|
||||||
expiry = datetime.today() + timedelta(days=1)
|
expiry = datetime.today() + timedelta(days=1)
|
||||||
print("expiry===>", expiry, '===>', type(expiry))
|
|
||||||
email_data, created = UserEmailOtp.objects.get_or_create(email=request.data['email'])
|
email_data, created = UserEmailOtp.objects.get_or_create(email=request.data['email'])
|
||||||
if created:
|
if created:
|
||||||
email_data.expired_at = expiry
|
email_data.expired_at = expiry
|
||||||
|
@ -6,8 +6,6 @@ from rest_framework import serializers
|
|||||||
from rest_framework_simplejwt.tokens import RefreshToken
|
from rest_framework_simplejwt.tokens import RefreshToken
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.validators import URLValidator
|
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
"""Import Django app"""
|
"""Import Django app"""
|
||||||
from .models import Guardian, JuniorTask
|
from .models import Guardian, JuniorTask
|
||||||
from account.models import UserProfile, UserEmailOtp
|
from account.models import UserProfile, UserEmailOtp
|
||||||
@ -129,9 +127,7 @@ class CreateGuardianSerializer(serializers.ModelSerializer):
|
|||||||
if image:
|
if image:
|
||||||
filename = f"images/{image.name}"
|
filename = f"images/{image.name}"
|
||||||
image_url = upload_image_to_alibaba(image, filename)
|
image_url = upload_image_to_alibaba(image, filename)
|
||||||
print("image_url=====>",image_url,'===>',type(image_url))
|
|
||||||
guardian.image = image_url
|
guardian.image = image_url
|
||||||
print("guardian.image=====>", guardian.image,'===>',type(guardian.image))
|
|
||||||
guardian.save()
|
guardian.save()
|
||||||
return guardian
|
return guardian
|
||||||
|
|
||||||
@ -226,37 +222,3 @@ class TopJuniorSerializer(serializers.ModelSerializer):
|
|||||||
return item['total_points']
|
return item['total_points']
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#
|
|
||||||
# class TopJuniorSerializer(serializers.ModelSerializer):
|
|
||||||
# total_points = serializers.SerializerMethodField()
|
|
||||||
#
|
|
||||||
# email = serializers.SerializerMethodField('get_auth')
|
|
||||||
# first_name = serializers.SerializerMethodField('get_first_name')
|
|
||||||
# last_name = serializers.SerializerMethodField('get_last_name')
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# def get_auth(self, obj):
|
|
||||||
# return obj.auth.username
|
|
||||||
#
|
|
||||||
# def get_first_name(self, obj):
|
|
||||||
# return obj.auth.first_name
|
|
||||||
#
|
|
||||||
# def get_last_name(self, obj):
|
|
||||||
# print("onbj==>",obj)
|
|
||||||
# return obj.auth.last_name
|
|
||||||
#
|
|
||||||
# class Meta:
|
|
||||||
# model = Junior
|
|
||||||
# fields = ['id', 'email', 'first_name', 'last_name', 'phone', 'country_code', 'country_name', 'gender', 'dob', 'image', 'junior_code', 'guardian_code', 'referral_code', 'referral_code_used', 'is_active', 'is_complete_profile', 'passcode', 'is_verified', 'created_at', 'updated_at', 'total_points']
|
|
||||||
#
|
|
||||||
# def get_total_points(self, obj):
|
|
||||||
# total_highest_points = self.context.get('total_highest_points')
|
|
||||||
# if total_highest_points:
|
|
||||||
# print("total_highest_points==>",total_highest_points)
|
|
||||||
# junior_id = obj.id
|
|
||||||
# print("junior_id==>", junior_id)
|
|
||||||
# total_points = next((item['total_points'] for item in total_highest_points if item['junior'] == junior_id), 0)
|
|
||||||
# print("total_points==>", total_points)
|
|
||||||
# return total_points
|
|
||||||
# return 0
|
|
||||||
#
|
|
||||||
|
@ -32,7 +32,6 @@ class SignupViewset(viewsets.ModelViewSet):
|
|||||||
"""Generate otp"""
|
"""Generate otp"""
|
||||||
otp = generate_otp()
|
otp = generate_otp()
|
||||||
expiry = datetime.today() + timedelta(days=1)
|
expiry = datetime.today() + timedelta(days=1)
|
||||||
print("expiry===>", expiry, '===>', type(expiry))
|
|
||||||
UserEmailOtp.objects.create(email=request.data['email'], otp=otp,
|
UserEmailOtp.objects.create(email=request.data['email'], otp=otp,
|
||||||
user_type=str(request.data['user_type']), expired_at=expiry)
|
user_type=str(request.data['user_type']), expired_at=expiry)
|
||||||
"""Send email to the register user"""
|
"""Send email to the register user"""
|
||||||
@ -150,35 +149,3 @@ class TopJuniorListAPIView(viewsets.ModelViewSet):
|
|||||||
junior_ids_with_total_points})
|
junior_ids_with_total_points})
|
||||||
return custom_response(serializer.data, response_status=status.HTTP_200_OK)
|
return custom_response(serializer.data, response_status=status.HTTP_200_OK)
|
||||||
|
|
||||||
#
|
|
||||||
# class TopJuniorListAPIView(viewsets.ModelViewSet):
|
|
||||||
# """Top juniors list"""
|
|
||||||
# serializer_class = TopJuniorSerializer
|
|
||||||
# # permission_classes = [IsAuthenticated]
|
|
||||||
#
|
|
||||||
# def list(self, request, *args, **kwargs):
|
|
||||||
# """fetch junior list those complete their task"""
|
|
||||||
# total_highest_points = list(JuniorTask.objects.filter(task_status=1)
|
|
||||||
# .values('junior')
|
|
||||||
# .annotate(total_points=Sum('points'))
|
|
||||||
# .order_by('-total_points'))
|
|
||||||
# print("total_highest_points===>",total_highest_points,'===>',type(total_highest_points))
|
|
||||||
# junior_ids = [item['junior'] for item in total_highest_points]
|
|
||||||
# print("junior_ids====>", junior_ids)
|
|
||||||
# juniors = Junior.objects.filter(id__in=junior_ids)
|
|
||||||
# # a = []
|
|
||||||
# # for i in junior_ids:
|
|
||||||
# # juniors = Junior.objects.filter(id=i)
|
|
||||||
# # a.append(juniors)
|
|
||||||
# print("juniors====>", juniors)
|
|
||||||
# # print('a===>',a,'==>',type(a))
|
|
||||||
# serializer = self.get_serializer(juniors, context={'total_highest_points': total_highest_points}, many=True)
|
|
||||||
# print("serializer====>",type(serializer.data))
|
|
||||||
# # Find the junior with the highest points
|
|
||||||
# # highest_points_junior = max(serializer.data, key=lambda x: x['total_points'])
|
|
||||||
#
|
|
||||||
# return custom_response(serializer.data, response_status=status.HTTP_200_OK)
|
|
||||||
# # serializer = self.get_serializer(total_highest_points, many=True)
|
|
||||||
# # return custom_response(None, serializer.data,response_status=status.HTTP_200_OK)
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,15 +61,6 @@ class CreateJuniorSerializer(serializers.ModelSerializer):
|
|||||||
"""Create junior profile"""
|
"""Create junior profile"""
|
||||||
image = validated_data.get('image', None)
|
image = validated_data.get('image', None)
|
||||||
guardian_code = validated_data.get('guardian_code',None)
|
guardian_code = validated_data.get('guardian_code',None)
|
||||||
print("guardian_code===>",guardian_code,'==>',type(guardian_code))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# phone_number = validated_data.get('phone', None)
|
|
||||||
# guardian_data = Guardian.objects.filter(phone=phone_number)
|
|
||||||
# junior_data = Junior.objects.filter(phone=phone_number)
|
|
||||||
# if phone_number and (junior_data or guardian_data):
|
|
||||||
# raise serializers.ValidationError({"details":ERROR_CODE['2012']})
|
|
||||||
user = User.objects.filter(username=self.context['user']).last()
|
user = User.objects.filter(username=self.context['user']).last()
|
||||||
if user:
|
if user:
|
||||||
"""Save first and last name of junior"""
|
"""Save first and last name of junior"""
|
||||||
@ -167,7 +158,6 @@ class JuniorDetailListSerializer(serializers.ModelSerializer):
|
|||||||
return obj.auth.last_name
|
return obj.auth.last_name
|
||||||
|
|
||||||
def get_assigned_task(self, obj):
|
def get_assigned_task(self, obj):
|
||||||
print("obj===>",obj,'type==>',type(obj))
|
|
||||||
data = JuniorTask.objects.filter(junior=obj).count()
|
data = JuniorTask.objects.filter(junior=obj).count()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -48,6 +48,5 @@ class JuniorListAPIView(viewsets.ModelViewSet):
|
|||||||
""" junior list"""
|
""" junior list"""
|
||||||
guardian_data = Guardian.objects.filter(user__email=request.user).last()
|
guardian_data = Guardian.objects.filter(user__email=request.user).last()
|
||||||
queryset = Junior.objects.filter(guardian_code__icontains=str(guardian_data.guardian_code))
|
queryset = Junior.objects.filter(guardian_code__icontains=str(guardian_data.guardian_code))
|
||||||
print("queryset===>",queryset)
|
|
||||||
serializer = JuniorDetailListSerializer(queryset, many=True)
|
serializer = JuniorDetailListSerializer(queryset, many=True)
|
||||||
return custom_response(None, serializer.data, response_status=status.HTTP_200_OK)
|
return custom_response(None, serializer.data, response_status=status.HTTP_200_OK)
|
||||||
|
@ -19,6 +19,8 @@ click==8.1.3
|
|||||||
click-didyoumean==0.3.0
|
click-didyoumean==0.3.0
|
||||||
click-plugins==1.1.1
|
click-plugins==1.1.1
|
||||||
click-repl==0.3.0
|
click-repl==0.3.0
|
||||||
|
coreapi==2.3.3
|
||||||
|
coreschema==0.0.4
|
||||||
crcmod==1.7
|
crcmod==1.7
|
||||||
cron-descriptor==1.4.0
|
cron-descriptor==1.4.0
|
||||||
cryptography==41.0.1
|
cryptography==41.0.1
|
||||||
@ -43,8 +45,11 @@ google-auth==2.21.0
|
|||||||
gunicorn==20.1.0
|
gunicorn==20.1.0
|
||||||
idna==3.4
|
idna==3.4
|
||||||
inflection==0.5.1
|
inflection==0.5.1
|
||||||
|
itypes==1.2.0
|
||||||
|
Jinja2==3.1.2
|
||||||
jmespath==0.10.0
|
jmespath==0.10.0
|
||||||
kombu==5.3.1
|
kombu==5.3.1
|
||||||
|
MarkupSafe==2.1.3
|
||||||
msgpack==1.0.5
|
msgpack==1.0.5
|
||||||
oss2==2.18.0
|
oss2==2.18.0
|
||||||
packaging==23.1
|
packaging==23.1
|
||||||
|
Reference in New Issue
Block a user