marcsello
7a9d098107
All checks were successful
continuous-integration/drone/push Build is passing
- Creating a new new object when it isn't supposed - Serializing enum field
19 lines
443 B
Python
19 lines
443 B
Python
#!/usr/bin/env python3
|
|
from marshmallow import fields
|
|
from marshmallow_sqlalchemy import ModelSchema
|
|
from marshmallow_enum import EnumField
|
|
from model import AIModel, AIModelType
|
|
|
|
|
|
class AIModelSchema(ModelSchema):
|
|
|
|
default = fields.Method("boolize_default", dump_only=True)
|
|
|
|
type = EnumField(AIModelType)
|
|
|
|
def boolize_default(self, ai_model) -> bool:
|
|
return bool(ai_model.default)
|
|
|
|
class Meta:
|
|
model = AIModel
|