Changes author_id (uid) to owner_address (ethereum)
and receiver_id to receiver_address (just the name) + minor impvrovements
This commit is contained in:
parent
73937e0545
commit
8a0957f512
|
@ -383,18 +383,18 @@ class Computer(Device):
|
||||||
It is a subset of the Linux definition of DMI / DMI decode.
|
It is a subset of the Linux definition of DMI / DMI decode.
|
||||||
"""
|
"""
|
||||||
deposit = Column(Integer, check_range('deposit',min=0,max=100), default=0)
|
deposit = Column(Integer, check_range('deposit',min=0,max=100), default=0)
|
||||||
author_id = db.Column(UUID(as_uuid=True),
|
owner_address = db.Column(CIText(),
|
||||||
db.ForeignKey(User.id),
|
db.ForeignKey(User.ethereum_address),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=lambda: g.user.id)
|
default=lambda: g.user.ethereum_address)
|
||||||
author = db.relationship(User, primaryjoin=author_id == User.id)
|
author = db.relationship(User, primaryjoin=owner_address == User.ethereum_address)
|
||||||
transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False)
|
transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False)
|
||||||
transfer_state.comment = TransferState.__doc__
|
transfer_state.comment = TransferState.__doc__
|
||||||
receiver_id = db.Column(CIText(),
|
receiver_address = db.Column(CIText(),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.ethereum_address),
|
||||||
nullable=True)
|
nullable=True)
|
||||||
receiver = db.relationship(User, primaryjoin=receiver_id == User.ethereum_address)
|
receiver = db.relationship(User, primaryjoin=receiver_address == User.ethereum_address)
|
||||||
delivery_note_address = db.Column(CIText(), nullable=True)
|
deliverynote_address = db.Column(CIText(), nullable=True)
|
||||||
|
|
||||||
def __init__(self, chassis, **kwargs) -> None:
|
def __init__(self, chassis, **kwargs) -> None:
|
||||||
chassis = ComputerChassis(chassis)
|
chassis = ComputerChassis(chassis)
|
||||||
|
|
|
@ -142,19 +142,20 @@ class Computer(DisplayMixin, Device):
|
||||||
components = ... # type: Column
|
components = ... # type: Column
|
||||||
chassis = ... # type: Column
|
chassis = ... # type: Column
|
||||||
deposit = ... # type: Column
|
deposit = ... # type: Column
|
||||||
author_id = ... # type: Column
|
owner_address = ... # type: Column
|
||||||
transfer_state = ... # type: Column
|
transfer_state = ... # type: Column
|
||||||
receiver_id = ... # type: Column
|
receiver_address = ... # type: Column
|
||||||
delivery_note_address = ... # type: Column
|
deliverynote_address = ... # type: Column
|
||||||
|
|
||||||
def __init__(self, **kwargs) -> None:
|
def __init__(self, **kwargs) -> None:
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.components = ... # type: Set[Component]
|
self.components = ... # type: Set[Component]
|
||||||
self.actions_parent = ... # type: Set[e.Action]
|
self.actions_parent = ... # type: Set[e.Action]
|
||||||
self.chassis = ... # type: ComputerChassis
|
self.chassis = ... # type: ComputerChassis
|
||||||
self.author_id = ... # type: UUID
|
self.owner_address = ... # type: UUID
|
||||||
self.transfer_state = ...
|
self.transfer_state = ...
|
||||||
self.receiver_id = ... # type: str
|
self.receiver_address = ... # type: str
|
||||||
|
self.deliverynote_address = ... # type: str
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def actions(self) -> List:
|
def actions(self) -> List:
|
||||||
|
|
|
@ -126,10 +126,10 @@ class Computer(Device):
|
||||||
data_key='deposit',
|
data_key='deposit',
|
||||||
description=m.Computer.deposit.__doc__)
|
description=m.Computer.deposit.__doc__)
|
||||||
# author_id = NestedOn(s_user.User,only_query='author_id')
|
# author_id = NestedOn(s_user.User,only_query='author_id')
|
||||||
author_id = UUID(dump_only=True,
|
owner_address = SanitizedStr(validate=f.validate.Length(max=42))
|
||||||
data_key='author_id')
|
|
||||||
transfer_state = EnumField(enums.TransferState, description=m.Computer.transfer_state.comment)
|
transfer_state = EnumField(enums.TransferState, description=m.Computer.transfer_state.comment)
|
||||||
receiver_id = SanitizedStr(validate=f.validate.Length(max=42))
|
receiver_address = SanitizedStr(validate=f.validate.Length(max=42))
|
||||||
|
deliverynote_address = SanitizedStr(validate=f.validate.Length(max=42))
|
||||||
|
|
||||||
|
|
||||||
class Desktop(Computer):
|
class Desktop(Computer):
|
||||||
|
|
|
@ -63,18 +63,18 @@ class Lot(Thing):
|
||||||
descendants.
|
descendants.
|
||||||
"""
|
"""
|
||||||
deposit = db.Column(db.Integer, check_range('deposit', min=0, max=100), default=0)
|
deposit = db.Column(db.Integer, check_range('deposit', min=0, max=100), default=0)
|
||||||
author_id = db.Column(UUID(as_uuid=True),
|
owner_address = db.Column(CIText(),
|
||||||
db.ForeignKey(User.id),
|
db.ForeignKey(User.ethereum_address),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=lambda: g.user.id)
|
default=lambda: g.user.ethereum_address)
|
||||||
author = db.relationship(User, primaryjoin=author_id == User.id)
|
owner = db.relationship(User, primaryjoin=owner_address == User.ethereum_address)
|
||||||
transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False)
|
transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False)
|
||||||
transfer_state.comment = TransferState.__doc__
|
transfer_state.comment = TransferState.__doc__
|
||||||
receiver_id = db.Column(CIText(),
|
receiver_address = db.Column(CIText(),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.ethereum_address),
|
||||||
nullable=True)
|
nullable=True)
|
||||||
receiver = db.relationship(User, primaryjoin=receiver_id == User.ethereum_address)
|
receiver = db.relationship(User, primaryjoin=receiver_address == User.ethereum_address)
|
||||||
delivery_note_address = db.Column(CIText(), nullable=True)
|
deliverynote_address = db.Column(CIText(), nullable=True)
|
||||||
|
|
||||||
def __init__(self, name: str, closed: bool = closed.default.arg,
|
def __init__(self, name: str, closed: bool = closed.default.arg,
|
||||||
description: str = None) -> None:
|
description: str = None) -> None:
|
||||||
|
|
|
@ -25,11 +25,12 @@ class Lot(Thing):
|
||||||
all_devices = ... # type: relationship
|
all_devices = ... # type: relationship
|
||||||
parents = ... # type: relationship
|
parents = ... # type: relationship
|
||||||
deposit = ... # type: Column
|
deposit = ... # type: Column
|
||||||
author_id = ... # type: Column
|
owner_address = ... # type: Column
|
||||||
|
owner = ... # type: relationship
|
||||||
transfer_state = ... # type: Column
|
transfer_state = ... # type: Column
|
||||||
receiver_id = ... # type: Column
|
receiver_address = ... # type: Column
|
||||||
receiver = ... # type: relationship
|
receiver = ... # type: relationship
|
||||||
delivery_note_address = ... # type: Column
|
deliverynote_address = ... # type: Column
|
||||||
|
|
||||||
def __init__(self, name: str, closed: bool = closed.default.arg) -> None:
|
def __init__(self, name: str, closed: bool = closed.default.arg) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -42,9 +43,10 @@ class Lot(Thing):
|
||||||
self.all_devices = ... # type: Set[Device]
|
self.all_devices = ... # type: Set[Device]
|
||||||
self.parents = ... # type: Set[Lot]
|
self.parents = ... # type: Set[Lot]
|
||||||
self.children = ... # type: Set[Lot]
|
self.children = ... # type: Set[Lot]
|
||||||
self.author_id = ... # type: UUID
|
self.owner_address = ... # type: UUID
|
||||||
self.transfer_state = ...
|
self.transfer_state = ...
|
||||||
self.receiver_id = ... # type: str
|
self.receiver_address = ... # type: str
|
||||||
|
self.deliverynote_address = ... # type: str
|
||||||
|
|
||||||
def add_children(self, *children: Union[Lot, uuid.UUID]):
|
def add_children(self, *children: Union[Lot, uuid.UUID]):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Lot(Thing):
|
||||||
data_key='deposit',
|
data_key='deposit',
|
||||||
description=m.Lot.deposit.__doc__)
|
description=m.Lot.deposit.__doc__)
|
||||||
# author_id = NestedOn(s_user.User,only_query='author_id')
|
# author_id = NestedOn(s_user.User,only_query='author_id')
|
||||||
author_id = f.UUID(dump_only=True)
|
owner_address = SanitizedStr(validate=f.validate.Length(max=42))
|
||||||
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
|
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
|
||||||
receiver_id = SanitizedStr(validate=f.validate.Length(max=42))
|
receiver_address = SanitizedStr(validate=f.validate.Length(max=42))
|
||||||
|
deliverynote_address = SanitizedStr(validate=f.validate.Length(max=42))
|
|
@ -41,10 +41,10 @@ class LotView(View):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def patch(self, id):
|
def patch(self, id):
|
||||||
patch_schema = self.resource_def.SCHEMA(only=('name', 'description', 'transfer_state', 'receiver_id', 'deposit', 'delivery_note_address', 'devices', 'author_id'), partial=True)
|
patch_schema = self.resource_def.SCHEMA(only=('name', 'description', 'transfer_state', 'receiver_address', 'deposit', 'deliverynote_address', 'devices', 'owner_address'), partial=True)
|
||||||
l = request.get_json(schema=patch_schema)
|
l = request.get_json(schema=patch_schema)
|
||||||
lot = Lot.query.filter_by(id=id).one()
|
lot = Lot.query.filter_by(id=id).one()
|
||||||
device_fields = ['transfer_state', 'receiver_id', 'deposit', 'delivery_note_address', 'author_id']
|
device_fields = ['transfer_state', 'receiver_address', 'deposit', 'deliverynote_address', 'owner_address']
|
||||||
computers = [x for x in lot.all_devices if isinstance(x, Computer)]
|
computers = [x for x in lot.all_devices if isinstance(x, Computer)]
|
||||||
for key, value in l.items():
|
for key, value in l.items():
|
||||||
setattr(lot, key, value)
|
setattr(lot, key, value)
|
||||||
|
|
Reference in New Issue