fixing schema offer
This commit is contained in:
parent
1d6e0c9588
commit
84fac3f04a
|
@ -1453,13 +1453,11 @@ class Trade(JoinedTableMixin, ActionWithMultipleDevices):
|
||||||
confirm_transfer = Column(Boolean, default=False)
|
confirm_transfer = Column(Boolean, default=False)
|
||||||
confirm_transfer_comment = """Transfer of the phisical devices it is confirmed"""
|
confirm_transfer_comment = """Transfer of the phisical devices it is confirmed"""
|
||||||
offer_id = db.Column(UUID(as_uuid=True),
|
offer_id = db.Column(UUID(as_uuid=True),
|
||||||
db.ForeignKey('offer.id',
|
db.ForeignKey('offer.id'),
|
||||||
user_alter=True,
|
|
||||||
name='trade_offer'),
|
|
||||||
nullable=True)
|
nullable=True)
|
||||||
offer = db.relationship('offer',
|
offer = db.relationship('Offer',
|
||||||
backref=db.backref('trade', uselist=False, lazy=True),
|
backref=db.backref('trade', uselist=False, lazy=True),
|
||||||
primaryjoin='Trade.id == Offer.trade_id')
|
primaryjoin='Trade.offer_id == Offer.id')
|
||||||
|
|
||||||
|
|
||||||
class Offer(JoinedTableMixin, ActionWithMultipleDevices):
|
class Offer(JoinedTableMixin, ActionWithMultipleDevices):
|
||||||
|
|
|
@ -464,14 +464,18 @@ class Trade(ActionWithMultipleDevices):
|
||||||
offer = NestedOn('Offer', dump_only=True)
|
offer = NestedOn('Offer', dump_only=True)
|
||||||
|
|
||||||
|
|
||||||
class Offer(Trade):
|
class Offer(ActionWithMultipleDevices):
|
||||||
__doc__ = m.Trade.__doc__
|
__doc__ = m.Offer.__doc__
|
||||||
document_id = SanitizedStr(validate=Length(max=STR_SIZE), data_key='documentID', required=False)
|
document_id = SanitizedStr(validate=Length(max=STR_SIZE), data_key='documentID', required=False)
|
||||||
date = DateTime(data_key='date', required=False)
|
date = DateTime(data_key='date', required=False)
|
||||||
price = Float(required=False, data_key='price')
|
price = Float(required=False, data_key='price')
|
||||||
user_to_id = SanitizedStr(validate=Length(max=STR_SIZE), data_key='userTo', required=False)
|
user_to_id = SanitizedStr(validate=Length(max=STR_SIZE), data_key='userTo', required=False)
|
||||||
user_from_id = SanitizedStr(validate=Length(max=STR_SIZE), data_key='userTo', required=False)
|
user_from_id = SanitizedStr(validate=Length(max=STR_SIZE), data_key='userTo', required=False)
|
||||||
lot = NestedOn('Lot', dump_only=True)
|
# lot = NestedOn('Lot', dump_only=True)
|
||||||
|
lot = NestedOn('Lot',
|
||||||
|
many=False,
|
||||||
|
required=True, # todo test ensuring len(devices) >= 1
|
||||||
|
only_query='id')
|
||||||
|
|
||||||
@validates_schema
|
@validates_schema
|
||||||
def validate_user_to_id(self, data: dict):
|
def validate_user_to_id(self, data: dict):
|
||||||
|
|
|
@ -251,11 +251,9 @@ class ActionView(View):
|
||||||
# TODO JN add compute rate with new visual test and old components device
|
# TODO JN add compute rate with new visual test and old components device
|
||||||
if json['type'] == InitTransfer.t:
|
if json['type'] == InitTransfer.t:
|
||||||
return self.transfer_ownership()
|
return self.transfer_ownership()
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
a = resource_def.schema.load(json)
|
a = resource_def.schema.load(json)
|
||||||
Model = db.Model._decl_class_registry.data[json['type']]()
|
Model = db.Model._decl_class_registry.data[json['type']]()
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
# a['lot_id'] = a['lot'].id
|
|
||||||
# a.pop('lot')
|
|
||||||
action = Model(**a)
|
action = Model(**a)
|
||||||
db.session.add(action)
|
db.session.add(action)
|
||||||
db.session().final_flush()
|
db.session().final_flush()
|
||||||
|
|
Reference in a new issue