2020-04-14 02:01:44 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from marshmallow import fields
|
|
|
|
from marshmallow_sqlalchemy import ModelSchema
|
2020-09-14 03:02:31 +02:00
|
|
|
from marshmallow_enum import EnumField
|
|
|
|
from model import AIModel, AIModelType
|
2020-04-14 02:01:44 +02:00
|
|
|
|
|
|
|
|
2020-04-14 13:48:11 +02:00
|
|
|
class AIModelSchema(ModelSchema):
|
2020-04-14 17:26:33 +02:00
|
|
|
|
|
|
|
default = fields.Method("boolize_default", dump_only=True)
|
|
|
|
|
2020-09-14 03:02:31 +02:00
|
|
|
type = EnumField(AIModelType)
|
|
|
|
|
2020-04-14 17:26:33 +02:00
|
|
|
def boolize_default(self, ai_model) -> bool:
|
|
|
|
return bool(ai_model.default)
|
|
|
|
|
2020-04-14 02:01:44 +02:00
|
|
|
class Meta:
|
2020-04-14 13:48:11 +02:00
|
|
|
model = AIModel
|