-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab7b322
commit 4f64cd5
Showing
15 changed files
with
148 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
"""Schema for WidgetPoll.""" | ||
"""Schema for Widget Poll.""" | ||
from met_api.models.widget_poll import Poll as PollModel | ||
from met_api.models.poll_answers import PollAnswer as PollAnswerModel | ||
from marshmallow import Schema | ||
from marshmallow_sqlalchemy.fields import Nested | ||
|
||
|
||
class PollAnswerSchema(Schema): | ||
""" | ||
Schema for serializing and deserializing Poll Answer data. | ||
This schema is used to represent poll answers in a structured format, | ||
facilitating operations like loading from and dumping to JSON. | ||
""" | ||
|
||
class Meta: | ||
model = PollAnswerModel | ||
fields = ('id', 'answer_text', 'poll_id') | ||
"""Meta class for PollAnswerSchema options.""" | ||
|
||
model = PollAnswerModel # The model representing Poll Answer. | ||
fields = ('id', 'answer_text', 'poll_id') # Fields to include in the schema. | ||
|
||
|
||
class WidgetPollSchema(Schema): | ||
""" | ||
Schema for serializing and deserializing Widget Poll data. | ||
This schema is designed to handle Widget Poll data, enabling easy conversion | ||
between Python objects and JSON representation, specifically for Widget Polls. | ||
""" | ||
|
||
class Meta: | ||
model = PollModel | ||
"""Meta class for WidgetPollSchema options.""" | ||
|
||
model = PollModel # The model representing Widget Poll. | ||
fields = ('id', 'title', 'description', 'status', 'widget_id', 'engagement_id', 'answers') | ||
|
||
answers = Nested(PollAnswerSchema, many=True) | ||
"""Nested field for Poll Answers. | ||
This field represents a collection of Poll Answers associated with a Widget Poll, | ||
allowing for the inclusion of related Poll Answer data within a Widget Poll's serialized form. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.