From 480afb3b1220f42bbaebc62efdafc907cf57b53f Mon Sep 17 00:00:00 2001 From: "jordi.nadeu" Date: Mon, 9 Dec 2019 17:24:24 +0100 Subject: [PATCH] first iteration integration with blockchain --- ereuse_devicehub/resources/action/models.py | 26 ++++++++++++++++++++ ereuse_devicehub/resources/action/models.pyi | 4 +++ ereuse_devicehub/resources/action/schemas.py | 9 +++++++ 3 files changed, 39 insertions(+) diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index 8c04d708..94fa47bb 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -1452,6 +1452,32 @@ class Receive(JoinedTableMixin, ActionWithMultipleDevices): default=ReceiverRole.Intermediary) +class ShareDeliveryNote(JoinedTableMixin, ActionWithMultipleDevices): + """To share a DeliveryNote to between owners.""" + # New variables for DeliveryNote + supplier = db.Column() # String, nullable, ... + supplier.comment = """Name of the organization/agent that create DeliveryNote.""" + date_delivery_note = db.Column() + date_delivery_note.comment = """Date of note creation.""" + # Is the same of lot id?? + id_delivery_note = db.Column(UUID(as_uuid=True)) + id_delivery_note.comment = """Unique id of lot and delivery note.""" + deposit = db.Column() + deposit.comment = """Total amount of deposit devices in Lot.""" + address_note = db.Column(UUID(as_uuid=True)) + address_note.comment = """Address identifier in the blockchain.""" + + agent_id = Column(UUID(as_uuid=True), + ForeignKey(Agent.id), + nullable=False, + default=lambda: g.user.individual.id) + + +class ConfirmDeliveryNote(JoinedTableMixin, ActionWithMultipleDevices): + """To confirm a DeliveryNote that has been shared.""" + pass + + class Migrate(JoinedTableMixin, ActionWithMultipleDevices): """Moves the devices to a new database/inventory. Devices cannot be modified anymore at the previous database. diff --git a/ereuse_devicehub/resources/action/models.pyi b/ereuse_devicehub/resources/action/models.pyi index 61010fc8..c529fb46 100644 --- a/ereuse_devicehub/resources/action/models.pyi +++ b/ereuse_devicehub/resources/action/models.pyi @@ -537,6 +537,10 @@ class Receive(ActionWithMultipleDevices): self.role = ... # type: ReceiverRole +class ShareDeliveryNote(ActionWithMultipleDevices): + pass + + class Migrate(ActionWithMultipleDevices): other = ... # type: Column diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index bb23f7b2..e92c9bbb 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -442,6 +442,15 @@ class Receive(ActionWithMultipleDevices): role = EnumField(ReceiverRole) +class ShareDeliveryNote(ActionWithMultipleDevices): + __doc__ = m.ShareDeliveryNote.__doc__ + supplier = SanitizedStr(validate=Length(max=STR_SIZE), data_key='supplierName') + date_delivery_note = DateTime(data_key='dateDeliveryNote') + deposit = Integer(data_key='depositValue') + address_note = UUID(dump_only=True) + id_delivery_note = UUID(dump_only=True) + + class Migrate(ActionWithMultipleDevices): __doc__ = m.Migrate.__doc__ other = URL()