mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 05:42:27 +00:00
added to user type as per required changes, handled apple signup for existing users
This commit is contained in:
@ -184,7 +184,7 @@ class SigninWithApple(views.APIView):
|
||||
user_data = {"email": decoded_data.get('email'), "username": decoded_data.get('email'), "is_active": True}
|
||||
if decoded_data.get("email"):
|
||||
try:
|
||||
user = User.objects.get(email=decoded_data.get("email"))
|
||||
user = User.objects.get(email__iexact=decoded_data.get("email"))
|
||||
if str(user_type) == '1':
|
||||
junior_data = Junior.objects.filter(auth=user).last()
|
||||
if not junior_data:
|
||||
|
@ -11,7 +11,7 @@ import tempfile
|
||||
# Import date time module's function
|
||||
from datetime import datetime, time
|
||||
# import Number constant
|
||||
from base.constants import NUMBER
|
||||
from base.constants import NUMBER, GUARDIAN
|
||||
# Import Junior's model
|
||||
from junior.models import Junior, JuniorPoints
|
||||
# Import guardian's model
|
||||
@ -117,7 +117,7 @@ def update_referral_points(referral_code, referral_code_used):
|
||||
junior_query.total_points = junior_query.total_points + NUMBER['five']
|
||||
junior_query.referral_points = junior_query.referral_points + NUMBER['five']
|
||||
junior_query.save()
|
||||
send_notification.delay(REFERRAL_POINTS, None, None, junior_queryset.auth_id, {})
|
||||
send_notification.delay(REFERRAL_POINTS, None, GUARDIAN, junior_queryset.auth_id, {})
|
||||
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ from junior.models import Junior, JuniorPoints, JuniorGuardianRelationship, Juni
|
||||
from guardian.tasks import generate_otp
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from base.constants import (PENDING, IN_PROGRESS, REJECTED, REQUESTED, COMPLETED, NUMBER, JUN, ZOD, EXPIRED,
|
||||
GUARDIAN_CODE_STATUS, JUNIOR)
|
||||
GUARDIAN_CODE_STATUS, JUNIOR, GUARDIAN)
|
||||
from guardian.models import Guardian, JuniorTask
|
||||
from account.models import UserEmailOtp, UserNotification
|
||||
from junior.utils import junior_notification_email, junior_approval_mail, get_junior_leaderboard_rank
|
||||
@ -323,7 +323,7 @@ class AddJuniorSerializer(serializers.ModelSerializer):
|
||||
"""Notification email"""
|
||||
junior_notification_email.delay(email, full_name, email, special_password)
|
||||
# push notification
|
||||
send_notification.delay(ASSOCIATE_JUNIOR, None, None, junior_data.auth_id, {})
|
||||
send_notification.delay(ASSOCIATE_JUNIOR, None, GUARDIAN, junior_data.auth_id, {})
|
||||
return junior_data
|
||||
|
||||
|
||||
|
@ -362,7 +362,7 @@ class RemoveJuniorAPIView(views.APIView):
|
||||
# save serializer
|
||||
serializer.save()
|
||||
JuniorGuardianRelationship.objects.filter(guardian=guardian, junior=junior_queryset).delete()
|
||||
send_notification.delay(REMOVE_JUNIOR, None, None, junior_queryset.auth_id, {})
|
||||
send_notification.delay(REMOVE_JUNIOR, None, GUARDIAN, junior_queryset.auth_id, {})
|
||||
return custom_response(SUCCESS_CODE['3022'], serializer.data, response_status=status.HTTP_200_OK)
|
||||
return custom_error_response(serializer.errors, response_status=status.HTTP_400_BAD_REQUEST)
|
||||
else:
|
||||
@ -712,7 +712,7 @@ class CompleteArticleAPIView(views.APIView):
|
||||
total_earn_points=Sum('earn_points'))['total_earn_points']
|
||||
data = {"total_earn_points":total_earn_points}
|
||||
if total_earn_points:
|
||||
send_notification.delay(ARTICLE_REWARD_POINTS, None, None,
|
||||
send_notification.delay(ARTICLE_REWARD_POINTS, None, GUARDIAN,
|
||||
request.user.id, {'points': total_earn_points})
|
||||
return custom_response(SUCCESS_CODE['3042'], data, response_status=status.HTTP_200_OK)
|
||||
except Exception as e:
|
||||
|
@ -92,6 +92,7 @@ def get_notification_data(notification_type, from_user_id, from_user_type, to_us
|
||||
|
||||
notification_data['from_user'] = from_user_name
|
||||
notification_data['from_user_image'] = from_user_image
|
||||
notification_data['to_user_type'] = GUARDIAN if from_user_type == JUNIOR else JUNIOR
|
||||
|
||||
notification_data.update(extra_data)
|
||||
to_user = User.objects.filter(id=to_user_id).first()
|
||||
|
@ -59,7 +59,8 @@ class NotificationViewSet(viewsets.GenericViewSet):
|
||||
notify_task_expiry()
|
||||
notify_top_junior()
|
||||
notification_type = request.query_params.get('type', TEST_NOTIFICATION)
|
||||
send_notification(int(notification_type), None, None, request.auth.payload['user_id'],
|
||||
from_user_type = request.query_params.get('from_user_type')
|
||||
send_notification(int(notification_type), None, from_user_type, request.auth.payload['user_id'],
|
||||
{})
|
||||
if notification_type and request.query_params.get('clear_all'):
|
||||
Notification.objects.filter(notification_type=notification_type).delete()
|
||||
|
Reference in New Issue
Block a user