Convertes expected_devices into a JSON Array,

closes #10
This commit is contained in:
emmdim 2020-03-11 18:39:58 +01:00
parent 81618a9e1b
commit 2810990fda
2 changed files with 7 additions and 5 deletions

View File

@ -4,8 +4,9 @@ from datetime import datetime
from boltons import urlutils
from citext import CIText
from flask import g
from typing import Iterable
from sqlalchemy.types import ARRAY
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.dialects.postgresql import UUID, JSONB
from teal.db import CASCADE_OWN, check_range, IntEnum
from teal.resource import url_for_resource
@ -41,7 +42,8 @@ class Deliverynote(Thing):
# to SnapshotDelivery entity.
# At this stage of implementation they will treated as a
# comma-separated string of the devices expexted/transfered
expected_devices = db.Column(db.ARRAY(db.Integer, dimensions=1), nullable=False)
expected_devices = db.Column(JSONB, nullable=False)
# expected_devices = db.Column(db.ARRAY(JSONB, dimensions=1), nullable=False)
transferred_devices = db.Column(db.ARRAY(db.Integer, dimensions=1), nullable=True)
transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False)
transfer_state.comment = TransferState.__doc__
@ -56,7 +58,7 @@ class Deliverynote(Thing):
def __init__(self, document_id: str, deposit: str, date,
supplier_email: str,
expected_devices: str,
expected_devices: Iterable,
transfer_state: TransferState) -> None:
"""Initializes a delivery note
"""

View File

@ -24,6 +24,6 @@ class Deliverynote(Thing):
description=m.Deliverynote.deposit.__doc__)
ethereum_address = f.String(description='User identifier address inside the Blockchain',
data_key='ethereumAddress')
expected_devices = f.List(f.Integer(), required=True, data_key='expectedDevices')
expected_devices = f.List(f.Dict, required=True, data_key='expectedDevices')
transferred_devices = f.List(f.Integer(), required=False, data_key='transferredDevices')
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)