2021-07-29 12:54:58 +00:00
|
|
|
from marshmallow.fields import DateTime, Integer, validate, Boolean
|
2021-07-21 06:35:18 +00:00
|
|
|
from teal.marshmallow import SanitizedStr, URL
|
|
|
|
from ereuse_devicehub.resources.schemas import Thing
|
|
|
|
from ereuse_devicehub.resources.documents import models as m
|
|
|
|
# from marshmallow import ValidationError, validates_schema
|
|
|
|
|
|
|
|
|
2021-07-26 09:33:11 +00:00
|
|
|
class Document(Thing):
|
|
|
|
__doc__ = m.Document.__doc__
|
|
|
|
id = Integer(description=m.Document.id.comment, dump_only=True)
|
|
|
|
type = SanitizedStr(default='Document')
|
2021-07-29 12:54:58 +00:00
|
|
|
url = URL(description=m.Document.url.comment)
|
|
|
|
success = Boolean(description=m.Document.success.comment)
|
|
|
|
software = SanitizedStr(description=m.Document.software.comment)
|
2021-07-21 06:35:18 +00:00
|
|
|
date = DateTime(data_key='endTime',
|
|
|
|
required=False,
|
2021-07-26 09:33:11 +00:00
|
|
|
description=m.Document.date.comment)
|
2021-07-21 06:35:18 +00:00
|
|
|
id_document = SanitizedStr(data_key='documentId',
|
|
|
|
default='',
|
2021-07-26 09:33:11 +00:00
|
|
|
description=m.Document.id_document.comment)
|
2021-07-21 06:35:18 +00:00
|
|
|
file_name = SanitizedStr(data_key='filename',
|
|
|
|
default='',
|
2021-07-26 09:33:11 +00:00
|
|
|
description=m.Document.file_name.comment,
|
2021-07-21 06:35:18 +00:00
|
|
|
validate=validate.Length(max=100))
|
|
|
|
file_hash = SanitizedStr(data_key='hash',
|
|
|
|
default='',
|
2021-07-26 09:33:11 +00:00
|
|
|
description=m.Document.file_hash.comment,
|
2021-07-21 06:35:18 +00:00
|
|
|
validate=validate.Length(max=64))
|