diff --git a/account/views.py b/account/views.py index b240e44..e2f211a 100644 --- a/account/views.py +++ b/account/views.py @@ -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: diff --git a/guardian/utils.py b/guardian/utils.py index 3360285..6461912 100644 --- a/guardian/utils.py +++ b/guardian/utils.py @@ -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, {}) diff --git a/junior/serializers.py b/junior/serializers.py index 615c949..fadb55f 100644 --- a/junior/serializers.py +++ b/junior/serializers.py @@ -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 diff --git a/junior/views.py b/junior/views.py index 171c454..80cc89b 100644 --- a/junior/views.py +++ b/junior/views.py @@ -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: diff --git a/notifications/utils.py b/notifications/utils.py index 46509eb..0764db6 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -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() diff --git a/notifications/views.py b/notifications/views.py index 5fcafe8..e11a63b 100644 --- a/notifications/views.py +++ b/notifications/views.py @@ -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()