diff --git a/account/serializers.py b/account/serializers.py index 9380ba8..5d688b4 100644 --- a/account/serializers.py +++ b/account/serializers.py @@ -169,7 +169,6 @@ class JuniorSerializer(serializers.ModelSerializer): auth_token = serializers.SerializerMethodField('get_auth_token') def get_auth_token(self, obj): - print("obj===>",obj,'===>',type(obj)) refresh = RefreshToken.for_user(obj.auth) access_token = str(refresh.access_token) return access_token diff --git a/account/views.py b/account/views.py index 3c006d7..fd0cef2 100644 --- a/account/views.py +++ b/account/views.py @@ -186,7 +186,6 @@ class ForgotPasswordAPIView(views.APIView): ) expiry = datetime.today() + timedelta(days=1) - print("expiry===>", expiry, '===>', type(expiry)) user_data, created = UserEmailOtp.objects.get_or_create(email=email) if created: user_data.expired_at = expiry @@ -255,7 +254,6 @@ class UserLogin(viewsets.ViewSet): email_verified = UserEmailOtp.objects.filter(email=username).last() refresh = RefreshToken.for_user(user) access_token = str(refresh.access_token) - print("email_verified.user_type==>",email_verified.user_type) data = {"auth_token":access_token, "is_profile_complete": False, "user_type": email_verified.user_type, } @@ -339,7 +337,6 @@ class ReSendEmailOtp(viewsets.ModelViewSet): otp = generate_otp() if User.objects.filter(email=request.data['email']): expiry = datetime.today() + timedelta(days=1) - print("expiry===>", expiry, '===>', type(expiry)) email_data, created = UserEmailOtp.objects.get_or_create(email=request.data['email']) if created: email_data.expired_at = expiry diff --git a/guardian/serializers.py b/guardian/serializers.py index a55c320..f85affc 100644 --- a/guardian/serializers.py +++ b/guardian/serializers.py @@ -6,8 +6,6 @@ from rest_framework import serializers from rest_framework_simplejwt.tokens import RefreshToken from django.db import transaction from django.contrib.auth.models import User -from django.core.validators import URLValidator -from django.core.exceptions import ValidationError """Import Django app""" from .models import Guardian, JuniorTask from account.models import UserProfile, UserEmailOtp @@ -129,9 +127,7 @@ class CreateGuardianSerializer(serializers.ModelSerializer): if image: filename = f"images/{image.name}" image_url = upload_image_to_alibaba(image, filename) - print("image_url=====>",image_url,'===>',type(image_url)) guardian.image = image_url - print("guardian.image=====>", guardian.image,'===>',type(guardian.image)) guardian.save() return guardian @@ -226,37 +222,3 @@ class TopJuniorSerializer(serializers.ModelSerializer): return item['total_points'] 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 -# diff --git a/guardian/views.py b/guardian/views.py index 6b7bf9b..5418565 100644 --- a/guardian/views.py +++ b/guardian/views.py @@ -32,7 +32,6 @@ class SignupViewset(viewsets.ModelViewSet): """Generate otp""" otp = generate_otp() expiry = datetime.today() + timedelta(days=1) - print("expiry===>", expiry, '===>', type(expiry)) 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""" @@ -150,35 +149,3 @@ class TopJuniorListAPIView(viewsets.ModelViewSet): junior_ids_with_total_points}) 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) - - diff --git a/junior/serializers.py b/junior/serializers.py index 8e871cd..5802a9c 100644 --- a/junior/serializers.py +++ b/junior/serializers.py @@ -61,15 +61,6 @@ class CreateJuniorSerializer(serializers.ModelSerializer): """Create junior profile""" image = validated_data.get('image', 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() if user: """Save first and last name of junior""" @@ -167,7 +158,6 @@ class JuniorDetailListSerializer(serializers.ModelSerializer): return obj.auth.last_name def get_assigned_task(self, obj): - print("obj===>",obj,'type==>',type(obj)) data = JuniorTask.objects.filter(junior=obj).count() return data diff --git a/junior/views.py b/junior/views.py index fd2555e..89c177f 100644 --- a/junior/views.py +++ b/junior/views.py @@ -48,6 +48,5 @@ class JuniorListAPIView(viewsets.ModelViewSet): """ junior list""" guardian_data = Guardian.objects.filter(user__email=request.user).last() queryset = Junior.objects.filter(guardian_code__icontains=str(guardian_data.guardian_code)) - print("queryset===>",queryset) serializer = JuniorDetailListSerializer(queryset, many=True) return custom_response(None, serializer.data, response_status=status.HTTP_200_OK) diff --git a/requirements.txt b/requirements.txt index 1103c6a..5dd7f76 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,6 +19,8 @@ click==8.1.3 click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.3.0 +coreapi==2.3.3 +coreschema==0.0.4 crcmod==1.7 cron-descriptor==1.4.0 cryptography==41.0.1 @@ -43,8 +45,11 @@ google-auth==2.21.0 gunicorn==20.1.0 idna==3.4 inflection==0.5.1 +itypes==1.2.0 +Jinja2==3.1.2 jmespath==0.10.0 kombu==5.3.1 +MarkupSafe==2.1.3 msgpack==1.0.5 oss2==2.18.0 packaging==23.1