2018-08-08 19:25:53 +00:00
|
|
|
from marshmallow import fields as f
|
2018-10-05 15:13:23 +00:00
|
|
|
from teal.marshmallow import SanitizedStr, URL
|
2018-08-08 19:25:53 +00:00
|
|
|
|
|
|
|
from ereuse_devicehub.marshmallow import NestedOn
|
2019-02-03 16:12:53 +00:00
|
|
|
from ereuse_devicehub.resources.device import schemas as s_device
|
2018-08-08 19:25:53 +00:00
|
|
|
from ereuse_devicehub.resources.lot import models as m
|
|
|
|
from ereuse_devicehub.resources.models import STR_SIZE
|
|
|
|
from ereuse_devicehub.resources.schemas import Thing
|
|
|
|
|
|
|
|
|
|
|
|
class Lot(Thing):
|
|
|
|
id = f.UUID(dump_only=True)
|
2018-09-30 10:29:33 +00:00
|
|
|
name = SanitizedStr(validate=f.validate.Length(max=STR_SIZE), required=True)
|
2018-11-06 17:08:57 +00:00
|
|
|
description = SanitizedStr(description=m.Lot.description.comment)
|
2018-09-11 19:50:40 +00:00
|
|
|
closed = f.Boolean(missing=False, description=m.Lot.closed.comment)
|
2019-02-03 16:12:53 +00:00
|
|
|
devices = NestedOn(s_device.Device, many=True, dump_only=True)
|
2018-09-12 12:53:14 +00:00
|
|
|
children = NestedOn('Lot', many=True, dump_only=True)
|
|
|
|
parents = NestedOn('Lot', many=True, dump_only=True)
|
2018-10-05 15:13:23 +00:00
|
|
|
url = URL(dump_only=True, description=m.Lot.url.__doc__)
|