add new attributes in Lot and User models
This commit is contained in:
parent
0898a41e62
commit
a85ebf0a8b
|
@ -71,7 +71,12 @@ class Lot(Thing):
|
||||||
author = db.relationship(User, primaryjoin=author_id == User.id)
|
author = db.relationship(User, primaryjoin=author_id == User.id)
|
||||||
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 = db.Column(CIText(), default='', nullable=False)
|
receiver_id = db.Column(UUID(as_uuid=False),
|
||||||
|
db.ForeignKey(User.ethereum_address),
|
||||||
|
nullable=True,
|
||||||
|
default=lambda: g.user.ethereum_address)
|
||||||
|
receiver = db.relationship(User, primaryjoin=receiver_id == User.ethereum_address)
|
||||||
|
delivery_note_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:
|
||||||
|
|
|
@ -27,7 +27,9 @@ class Lot(Thing):
|
||||||
deposit = ... # type: Column
|
deposit = ... # type: Column
|
||||||
author_id = ... # type: Column
|
author_id = ... # type: Column
|
||||||
transfer_state = ... # type: Column
|
transfer_state = ... # type: Column
|
||||||
receiver = ... # type: Column
|
receiver_id = ... # type: Column
|
||||||
|
receiver = ... # type: relationship
|
||||||
|
delivery_note_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__()
|
||||||
|
|
|
@ -23,5 +23,5 @@ class Lot(Thing):
|
||||||
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)
|
author_id = f.UUID(dump_only=True)
|
||||||
tranfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
|
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
|
||||||
receiver = SanitizedStr(validate=f.validate.Length(max=42))
|
receiver_id = SanitizedStr(validate=f.validate.Length(max=42))
|
|
@ -24,6 +24,7 @@ class User(Thing):
|
||||||
backref=db.backref('users', lazy=True, collection_class=set),
|
backref=db.backref('users', lazy=True, collection_class=set),
|
||||||
secondary=lambda: UserInventory.__table__,
|
secondary=lambda: UserInventory.__table__,
|
||||||
collection_class=set)
|
collection_class=set)
|
||||||
|
ethereum_address = Column(UUID(as_uuid=False), unique=True)
|
||||||
|
|
||||||
# todo set restriction that user has, at least, one active db
|
# todo set restriction that user has, at least, one active db
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ class User(Thing):
|
||||||
password = ... # type: Column
|
password = ... # type: Column
|
||||||
token = ... # type: Column
|
token = ... # type: Column
|
||||||
inventories = ... # type: relationship
|
inventories = ... # type: relationship
|
||||||
|
ethereum_address = ... # type: Column
|
||||||
|
|
||||||
def __init__(self, email: str, password: str = None,
|
def __init__(self, email: str, password: str = None,
|
||||||
inventories: Set[Inventory] = None) -> None:
|
inventories: Set[Inventory] = None) -> None:
|
||||||
|
|
|
@ -19,6 +19,7 @@ class User(Thing):
|
||||||
description='Use this token in an Authorization header to access the app.'
|
description='Use this token in an Authorization header to access the app.'
|
||||||
'The token can change overtime.')
|
'The token can change overtime.')
|
||||||
inventories = NestedOn(Inventory, many=True, dump_only=True)
|
inventories = NestedOn(Inventory, many=True, dump_only=True)
|
||||||
|
ethereum_address = String(description='User identifier address inside the Blockchain')
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
only=None,
|
only=None,
|
||||||
|
|
Reference in a new issue