From 4a554272a06489e16322229f9960121d10838ebd Mon Sep 17 00:00:00 2001 From: abutalib-kiwi Date: Fri, 8 Sep 2023 16:41:59 +0530 Subject: [PATCH] check answer api fixed --- junior/views.py | 4 ++-- notifications/utils.py | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/junior/views.py b/junior/views.py index 0dd632d..71a09b0 100644 --- a/junior/views.py +++ b/junior/views.py @@ -643,10 +643,10 @@ class CheckAnswerAPIView(viewsets.ModelViewSet): answer_id = self.request.GET.get('answer_id') current_page = self.request.GET.get('current_page') queryset = self.get_queryset() - submit_ans = SurveyOption.objects.filter(id=answer_id, is_answer=True).last() + submit_ans = SurveyOption.objects.filter(id=answer_id).last() junior_article_points = JuniorArticlePoints.objects.filter(junior__auth=self.request.user, question=queryset) - if submit_ans: + if submit_ans.is_answer: junior_article_points.update(submitted_answer=submit_ans, is_attempt=True, is_answer_correct=True) JuniorPoints.objects.filter(junior__auth=self.request.user).update(total_points= F('total_points') + queryset.points) diff --git a/notifications/utils.py b/notifications/utils.py index bd2a8bd..83e3e95 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -104,7 +104,6 @@ def send_notification(notification_type, from_user_id, from_user_type, to_user_i notification_data, push_data, from_user, to_user = get_notification_data(notification_type, from_user_id, from_user_type, to_user_id, extra_data) user_notification_type = UserNotification.objects.filter(user=to_user).first() - notification_data.update({'badge': Notification.objects.filter(notification_to=to_user, is_read=False).count()}) Notification.objects.create(notification_type=notification_type, notification_from=from_user, notification_to=to_user, data=notification_data) if user_notification_type and user_notification_type.push_notification: @@ -139,13 +138,10 @@ def send_notification_multiple_user(notification_type, from_user_id, from_user_t notification_list = [] for user in to_user_list: - notification_copy_data = notification_data.copy() - notification_copy_data.update( - {'badge': Notification.objects.filter(notification_to=user, is_read=False).count()}) notification_list.append(Notification(notification_type=notification_type, notification_to=user, notification_from=from_user, - data=notification_copy_data)) + data=notification_data)) Notification.objects.bulk_create(notification_list) to_user_list = to_user_list.filter(user_notification__push_notification=True) send_multiple_push(to_user_list, push_data)