2021-06-22 14:53:10 +00:00
|
|
|
from marshmallow.fields import DateTime, Integer, validate
|
2021-06-15 10:38:02 +00:00
|
|
|
from teal.marshmallow import SanitizedStr, URL
|
|
|
|
# from marshmallow import ValidationError, validates_schema
|
2021-05-13 11:35:46 +00:00
|
|
|
|
2021-05-19 07:47:14 +00:00
|
|
|
from ereuse_devicehub.marshmallow import NestedOn
|
2021-05-13 11:35:46 +00:00
|
|
|
from ereuse_devicehub.resources.schemas import Thing
|
|
|
|
from ereuse_devicehub.resources.tradedocument import models as m
|
2021-06-07 11:10:28 +00:00
|
|
|
# from ereuse_devicehub.resources.lot import schemas as s_lot
|
2021-05-13 11:35:46 +00:00
|
|
|
|
|
|
|
|
2021-05-14 10:58:56 +00:00
|
|
|
class TradeDocument(Thing):
|
|
|
|
__doc__ = m.TradeDocument.__doc__
|
|
|
|
id = Integer(description=m.TradeDocument.id.comment, dump_only=True)
|
|
|
|
date = DateTime(required=False, description=m.TradeDocument.date.comment)
|
2021-06-15 10:38:02 +00:00
|
|
|
id_document = SanitizedStr(data_key='documentId',
|
|
|
|
default='',
|
|
|
|
description=m.TradeDocument.id_document.comment)
|
|
|
|
description = SanitizedStr(default='',
|
2021-06-22 14:53:10 +00:00
|
|
|
description=m.TradeDocument.description.comment,
|
|
|
|
validate=validate.Length(max=500))
|
2021-06-15 10:38:02 +00:00
|
|
|
file_name = SanitizedStr(data_key='filename',
|
|
|
|
default='',
|
2021-06-22 14:53:10 +00:00
|
|
|
description=m.TradeDocument.file_name.comment,
|
|
|
|
validate=validate.Length(max=100))
|
2021-06-15 10:38:02 +00:00
|
|
|
file_hash = SanitizedStr(data_key='hash',
|
|
|
|
default='',
|
2021-06-22 14:53:10 +00:00
|
|
|
description=m.TradeDocument.file_hash.comment,
|
|
|
|
validate=validate.Length(max=64))
|
2021-06-15 10:38:02 +00:00
|
|
|
url = URL(description=m.TradeDocument.url.comment)
|
2021-06-07 11:10:28 +00:00
|
|
|
lot = NestedOn('Lot', only_query='id', description=m.TradeDocument.lot.__doc__)
|
2021-06-22 14:53:10 +00:00
|
|
|
trading = SanitizedStr(dump_only=True, description='')
|