class ClientTemplateSchema(ma.Schema): sessions = ma.Nested(PartialClientSessionSchema, many=True) user = ma.Nested(PartialUserSchema, many=False) class Meta: fields = ('id', 'name', 'slug', 'start_date', 'end_date', 'user_id', 'completed', 'sessions', 'user', 'active')
class ClientSessionSchema(ma.Schema): exercises = ma.Nested(ClientExerciseSchema, many=True) training_entries = ma.Nested(TrainingEntrySchema, many=True) class Meta: fields = ('id', 'client_weight', 'comment', 'name', 'slug', 'order', 'completed', 'client_template_id', 'exercises', 'training_entries', 'completed_date')
class ReaderSchema(ma.SQLAlchemyAutoSchema): class Meta: model = Reader include_relationships = True exclude = ("password", ) collections = ma.Nested(CollectionSchema, many=True, only=["id", "name"]) followers = ma.Nested(SimpleReader, many=True) follows = ma.Nested(SimpleReader, many=True) roles = ma.Function(lambda user: user.roles.split(","))
class CollectionSchema(ma.SQLAlchemyAutoSchema): class Meta: model = Collection include_relationships = True exclude = ("book_memberships", ) books = ma.Nested(BookSchema, many=True)
class CardSchema(ma.ModelSchema): id = fields.Int(required=True) activity_id = fields.Int(required=True) github_raw_data = fields.Str(required=True) content = fields.Str(required=True) gems = fields.Int(required=True) name = fields.Str(required=True) # activity is used to keep track of which activity that the card belongs to concepts = ma.Nested("ConceptSchema", only=("id", ), many=True) hints = ma.Nested("HintSchema", only=("id", "hints"), many=True) checkpoint = ma.Nested("CheckpointSchema", only=("id", )) class Meta: # Fields to show when sending data fields = ("id", "activity_id", "content", "gems", "name", "concepts", "hints", "checkpoint") ordered = True
class TopicSchema(ma.ModelSchema): id = fields.Int(required=True) name = fields.Str(required=True) description = fields.Str(required=True) image = fields.Str(required=True) modules = ma.Nested("ModuleSchema", only=("id", "name"), many=True) class Meta: # Fields to show when sending data fields = ("id", "name", "description", "modules") ordered = True
class ModuleSchema(ma.Schema): id = fields.Int(required=True) name = fields.Str(required=True) description = fields.Str(required=True) gems_needed = fields.Int(required=True) image = fields.Str(required=True) activities = ma.Nested("ActivitySchema", only=("id", "is_project"), many=True) class Meta: # Fields to show when sending data fields = ("id", "name", "description", "gems_needed", "image", "activities") ordered = True
class ReviewSchema(ma.SQLAlchemyAutoSchema): class Meta: model = Review include_relationships = True reader = ma.Nested(SimpleReader)
class GenreSchema(ma.SQLAlchemyAutoSchema): class Meta: model = Genre include_relationships = True books = ma.Nested(BookSchema, many=True)
class TrainingLogSchema(ma.Schema): training_entries = ma.Nested(TrainingEntrySchema, many=True) class Meta: fields = ('id', 'name', 'order', 'slug', 'completed', 'completed_date', 'training_entries')
class CoachTemplateSchema(ma.Schema): sessions = ma.Nested(PartialCoachSessionSchema, many=True) class Meta: fields = ('id', 'name', 'sessions', 'slug')
class CoachSessionSchema(ma.Schema): coach_exercises = ma.Nested(CoachExerciseSchema, many=True) class Meta: fields = ('id', 'name', 'slug', 'order', 'coach_template_id', 'coach_exercises')