Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import app.core.models as models
import app.core.schemas as schemas
from app.core import ma
from marshmallow import fields as fields2
from marshmallow_sqlalchemy import fields
class RichSchema(ma.SQLAlchemySchema):
class Meta:
strict = True
load_instance = True
include_relationships = True
class UserSchemaRich(RichSchema):
class Meta(RichSchema.Meta):
model = models.User
id = ma.auto_field()
name = ma.auto_field()
email = ma.auto_field()
role = fields.Nested(schemas.RoleSchema, many=False)
city = fields.Nested(schemas.CitySchema, many=False)
class CompetitionSchemaRich(RichSchema):
class Meta(RichSchema.Meta):
model = models.Competition
id = ma.auto_field()
name = ma.auto_field()
year = ma.auto_field()
slides = fields.Nested(schemas.SlideSchema, many=True)
city = fields.Nested(schemas.CitySchema, many=False)
class UserListSchema(ma.Schema):
users = fields2.Nested(UserSchemaRich, many=False)