added notification for getting points after reading article

This commit is contained in:
abutalib-kiwi
2023-08-25 19:08:15 +05:30
parent 9b6a84c7d1
commit 5b2ab2275e
5 changed files with 18 additions and 8 deletions

View File

@ -47,7 +47,7 @@ from account.utils import custom_response, custom_error_response
from guardian.utils import upload_image_to_alibaba
from .utils import update_positions_based_on_points
from notifications.utils import send_notification
from notifications.constants import REMOVE_JUNIOR
from notifications.constants import REMOVE_JUNIOR, ARTICLE_REWARD_POINTS
from web_admin.models import Article, ArticleSurvey, SurveyOption, ArticleCard
from web_admin.serializers.article_serializer import (ArticleSerializer, ArticleListSerializer,
StartAssessmentSerializer)
@ -666,6 +666,8 @@ class CompleteArticleAPIView(views.APIView):
is_answer_correct=True).aggregate(
total_earn_points=Sum('earn_points'))['total_earn_points']
data = {"total_earn_points":total_earn_points}
send_notification.delay(ARTICLE_REWARD_POINTS, None, None,
request.user.id, {'points': total_earn_points})
return custom_response(SUCCESS_CODE['3042'], data, response_status=status.HTTP_200_OK)
except Exception as e:
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)