mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-17 02:45:08 +00:00
some changes in artcle api
This commit is contained in:
@ -60,14 +60,14 @@ class ArticleSurveySerializer(serializers.ModelSerializer):
|
||||
article survey serializer
|
||||
"""
|
||||
id = serializers.IntegerField(required=False)
|
||||
survey_options = SurveyOptionSerializer(many=True)
|
||||
options = SurveyOptionSerializer(many=True)
|
||||
|
||||
class Meta:
|
||||
"""
|
||||
meta class
|
||||
"""
|
||||
model = ArticleSurvey
|
||||
fields = ('id', 'question', 'survey_options')
|
||||
fields = ('id', 'question', 'options')
|
||||
|
||||
|
||||
class ArticleSerializer(serializers.ModelSerializer):
|
||||
@ -120,7 +120,7 @@ class ArticleSerializer(serializers.ModelSerializer):
|
||||
|
||||
for survey in article_survey:
|
||||
survey = pop_id(survey)
|
||||
options = survey.pop('survey_options')
|
||||
options = survey.pop('options')
|
||||
survey_obj = ArticleSurvey.objects.create(article=article, points=ARTICLE_SURVEY_POINTS, **survey)
|
||||
for option in options:
|
||||
option = pop_id(option)
|
||||
@ -165,7 +165,7 @@ class ArticleSerializer(serializers.ModelSerializer):
|
||||
# Update or create survey sections
|
||||
for survey_data in article_survey:
|
||||
survey_id = survey_data.get('id', None)
|
||||
options_data = survey_data.pop('survey_options')
|
||||
options_data = survey_data.pop('options')
|
||||
if survey_id:
|
||||
survey = ArticleSurvey.objects.get(id=survey_id, article=instance)
|
||||
survey.question = survey_data.get('question', survey.question)
|
||||
|
Reference in New Issue
Block a user