mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
guardian list api changes
This commit is contained in:
@ -221,15 +221,20 @@ class ArticleListSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
article_cards = ArticleCardSerializer(many=True)
|
||||
total_points = serializers.SerializerMethodField('get_total_points')
|
||||
is_completed = serializers.SerializerMethodField('get_is_completed')
|
||||
|
||||
class Meta:
|
||||
"""
|
||||
meta class
|
||||
"""
|
||||
model = Article
|
||||
fields = ('id', 'title', 'description', 'article_cards', 'total_points')
|
||||
fields = ('id', 'title', 'description', 'article_cards', 'total_points', 'is_completed')
|
||||
|
||||
def get_total_points(self, obj):
|
||||
"""total points of article"""
|
||||
total_question = ArticleSurvey.objects.filter(article=obj).count()
|
||||
return total_question * 5
|
||||
|
||||
def get_is_completed(self, obj):
|
||||
"""complete all question"""
|
||||
return False
|
Reference in New Issue
Block a user