This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/resources/deliverynote/schemas.py

36 lines
1.4 KiB
Python
Raw Normal View History

2020-02-26 19:21:59 +00:00
from marshmallow import fields as f
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
2023-03-21 11:08:13 +00:00
from ereuse_devicehub.teal.marshmallow import EnumField, SanitizedStr
2020-02-26 19:21:59 +00:00
class Deliverynote(Thing):
2020-02-26 19:21:59 +00:00
id = f.UUID(dump_only=True)
2023-03-21 11:08:13 +00:00
document_id = SanitizedStr(
validate=f.validate.Length(max=STR_SIZE), required=True, data_key='documentID'
)
creator = NestedOn(s_user.User, dump_only=True)
2023-03-21 11:08:13 +00:00
supplier_email = SanitizedStr(
validate=f.validate.Length(max=STR_SIZE),
load_only=True,
required=True,
data_key='supplierEmail',
)
supplier = NestedOn(s_user.User, dump_only=True)
receiver = NestedOn(s_user.User, dump_only=True)
date = f.DateTime('iso', required=True)
2023-03-21 11:08:13 +00:00
amount = f.Integer(
validate=f.validate.Range(min=0, max=100),
description=m.Deliverynote.amount.__doc__,
)
expected_devices = f.List(f.Dict, required=True, data_key='expectedDevices')
2023-03-21 11:08:13 +00:00
transferred_devices = f.List(
f.Integer(), required=False, data_key='transferredDevices'
)
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)