adding isTemporary lot

This commit is contained in:
Cayo Puigdefabregas 2021-05-31 11:34:46 +02:00
parent 6142b89f41
commit e1348e3809
3 changed files with 6 additions and 0 deletions

View File

@ -99,6 +99,10 @@ class Lot(Thing):
def descendants(self): def descendants(self):
return self.descendantsq(self.id) return self.descendantsq(self.id)
@property
def is_temporary(self):
return False if self.trade else True
@classmethod @classmethod
def descendantsq(cls, id): def descendantsq(cls, id):
_id = UUIDLtree.convert(id) _id = UUIDLtree.convert(id)

View File

@ -26,3 +26,4 @@ class Lot(Thing):
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment) transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
receiver_address = SanitizedStr(validate=f.validate.Length(max=42)) receiver_address = SanitizedStr(validate=f.validate.Length(max=42))
deliverynote = NestedOn(s_deliverynote.Deliverynote, dump_only=True) deliverynote = NestedOn(s_deliverynote.Deliverynote, dump_only=True)
is_temporary = f.Boolean(missing=True, data_key='isTemporary')

View File

@ -32,6 +32,7 @@ class LotView(View):
def post(self): def post(self):
l = request.get_json() l = request.get_json()
l.pop('is_temporary', '')
lot = Lot(**l) lot = Lot(**l)
db.session.add(lot) db.session.add(lot)
db.session().final_flush() db.session().final_flush()