class PostSchema(ma.ModelSchema): class Meta: model = Post sqla_session = db.session user = ma.Nested(UserSchema) comment = ma.Nested(CommentSchema, many=True)
class PodcastSchema(ma.Schema): genres = ma.Nested(GenreSchema, many=True) class Meta: fields = ('id', 'name', 'kind', 'copyright', 'releaseDate', 'contentAdvisoryRating', 'url', 'artworkUrl100', 'artistName', 'artistId', 'artistUrl', 'genres')
class StoreSchema(ma.ModelSchema): items = ma.Nested(ItemSchema, many=True) class Meta: model = StoreModel load_only = ("store") dump_only = ("id",) # to link with Store id include_fk = True
class UserSchema(ma.ModelSchema): class Meta: model = UserModel load_only = ( "password", "confirmation_token", "created_at", ) dump_only = ("id", ) ordered = True company = ma.Nested(CompanyLoadSchema)
class UserSchema(ma.ModelSchema): email = ma.Email(required=True, validate=validate_email) password = ma.String(max_length=8, validate=validate.Length(min=6, max=10), required=True) profile = ma.Nested(ProfileSchema) class Meta: model = User fields = ('id', 'username', 'email', 'password', 'modified_on', 'profile') load_only = ('password', ) dump_only = ('id', 'modified_on')
class CompanyLoadSchema(ma.ModelSchema): name = ma.String() telephone = ma.String() default_off_days = ma.Int() address = ma.Nested(AddressSchema) employee_quota = ma.Nested(RemainingEmployeeSchema)
class OrgApplicationSchema(ma.ModelSchema): application = ma.Nested(ApplicationSchema) class Meta: model = OrgApplication
class CommentSchema(ma.ModelSchema): class Meta: model = Comment sqla_session = db.session user = ma.Nested(UserSchema)