Adds receiver column in Lot model and updates

Lot views PATCH to be able to modify the needed values
This commit is contained in:
emmdim 2019-12-14 22:11:28 +01:00 committed by nad
parent 047bac9096
commit 0898a41e62
4 changed files with 6 additions and 2 deletions

View File

@ -71,6 +71,7 @@ class Lot(Thing):
author = db.relationship(User, primaryjoin=author_id == User.id)
transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False)
transfer_state.comment = TransferState.__doc__
receiver = db.Column(CIText(), default='', nullable=False)
def __init__(self, name: str, closed: bool = closed.default.arg,
description: str = None) -> None:

View File

@ -27,6 +27,7 @@ class Lot(Thing):
deposit = ... # type: Column
author_id = ... # type: Column
transfer_state = ... # type: Column
receiver = ... # type: Column
def __init__(self, name: str, closed: bool = closed.default.arg) -> None:
super().__init__()
@ -41,6 +42,7 @@ class Lot(Thing):
self.children = ... # type: Set[Lot]
self.author_id = ... # type: UUID
self.transfer_state = ...
self.receiver = ... # type: str
def add_children(self, *children: Union[Lot, uuid.UUID]):
pass

View File

@ -23,4 +23,5 @@ class Lot(Thing):
description=m.Lot.deposit.__doc__)
# author_id = NestedOn(s_user.User,only_query='author_id')
author_id = f.UUID(dump_only=True)
tranfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
tranfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
receiver = SanitizedStr(validate=f.validate.Length(max=42))

View File

@ -40,7 +40,7 @@ class LotView(View):
return ret
def patch(self, id):
patch_schema = self.resource_def.SCHEMA(only=('name', 'description'), partial=True)
patch_schema = self.resource_def.SCHEMA(only=('name', 'description', 'transfer_state', 'receiver', 'deposit'), partial=True)
l = request.get_json(schema=patch_schema)
lot = Lot.query.filter_by(id=id).one()
if lot.transfer_state.name == 'Initial':