2020-02-26 19:21:59 +00:00
|
|
|
from marshmallow import fields as f
|
2020-08-17 14:45:18 +00:00
|
|
|
from teal.marshmallow import SanitizedStr, EnumField
|
2020-02-26 19:21:59 +00:00
|
|
|
|
|
|
|
from ereuse_devicehub.marshmallow import NestedOn
|
|
|
|
from ereuse_devicehub.resources.deliverynote import models as m
|
2020-08-17 14:45:18 +00:00
|
|
|
from ereuse_devicehub.resources.enums import TransferState
|
2020-02-26 19:21:59 +00:00
|
|
|
from ereuse_devicehub.resources.models import STR_SIZE
|
|
|
|
from ereuse_devicehub.resources.schemas import Thing
|
2020-08-17 14:45:18 +00:00
|
|
|
from ereuse_devicehub.resources.user import schemas as s_user
|
2020-02-26 19:21:59 +00:00
|
|
|
|
|
|
|
|
2020-02-27 17:29:26 +00:00
|
|
|
class Deliverynote(Thing):
|
2020-02-26 19:21:59 +00:00
|
|
|
id = f.UUID(dump_only=True)
|
2020-03-03 12:10:42 +00:00
|
|
|
document_id = SanitizedStr(validate=f.validate.Length(max=STR_SIZE),
|
|
|
|
required=True, data_key='documentID')
|
2020-03-03 19:32:04 +00:00
|
|
|
creator = NestedOn(s_user.User, dump_only=True)
|
|
|
|
supplier_email = SanitizedStr(validate=f.validate.Length(max=STR_SIZE),
|
2020-03-04 17:52:07 +00:00
|
|
|
load_only=True, required=True, data_key='supplierEmail')
|
2020-03-03 19:32:04 +00:00
|
|
|
supplier = NestedOn(s_user.User, dump_only=True)
|
|
|
|
receiver = NestedOn(s_user.User, dump_only=True)
|
2020-03-03 12:10:42 +00:00
|
|
|
date = f.DateTime('iso', required=True)
|
2020-03-03 19:32:04 +00:00
|
|
|
deposit = f.Integer(validate=f.validate.Range(min=0, max=100),
|
2020-08-17 14:45:18 +00:00
|
|
|
description=m.Deliverynote.deposit.__doc__)
|
2020-03-11 18:28:15 +00:00
|
|
|
ethereum_address = f.String(description='User identifier address inside the Blockchain')
|
2020-03-11 17:39:58 +00:00
|
|
|
expected_devices = f.List(f.Dict, required=True, data_key='expectedDevices')
|
2020-03-03 19:32:04 +00:00
|
|
|
transferred_devices = f.List(f.Integer(), required=False, data_key='transferredDevices')
|
2020-02-27 17:29:26 +00:00
|
|
|
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
|