Adds receiver column in Lot model and updates
Lot views PATCH to be able to modify the needed values
This commit is contained in:
parent
0f81be6878
commit
58ff2e69e2
|
@ -70,6 +70,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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -24,3 +24,4 @@ class Lot(Thing):
|
|||
# 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)
|
||||
receiver = SanitizedStr(validate=f.validate.Length(max=42))
|
|
@ -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()
|
||||
for key, value in l.items():
|
||||
|
|
Reference in a new issue