adding acctions into receives

This commit is contained in:
Cayo Puigdefabregas 2020-11-19 15:50:21 +01:00
parent cf3d44a5e3
commit 13ee6d09e6
3 changed files with 13 additions and 6 deletions

View file

@ -49,9 +49,11 @@ def upgrade():
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('agent_from_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('agent_from_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('agent_to_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('agent_to_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('action_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(['agent_from_id'], [f'{get_inv()}.agent.id'], ), sa.ForeignKeyConstraint(['agent_from_id'], [f'{get_inv()}.agent.id'], ),
sa.ForeignKeyConstraint(['agent_to_id'], [f'{get_inv()}.agent.id'], ), sa.ForeignKeyConstraint(['agent_to_id'], [f'{get_inv()}.agent.id'], ),
sa.ForeignKeyConstraint(['action_id'], [f'{get_inv()}.action.id'], ),
sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ),
sa.PrimaryKeyConstraint('id'), sa.PrimaryKeyConstraint('id'),
schema=f'{get_inv()}' schema=f'{get_inv()}'

View file

@ -1450,8 +1450,15 @@ class Receive(JoinedTableMixin, ActionWithMultipleDevices):
default=lambda: g.user.individual.id) default=lambda: g.user.individual.id)
agent_to = relationship(Agent, agent_to = relationship(Agent,
backref=backref('actions_agent', lazy=True, **_sorted_actions), backref=backref('actions_agent', lazy=True, **_sorted_actions),
primaryjoin=agent_to_id == Agent.id) primaryjoin=agent_to_id == Action.id)
agent_to_id.comment = """ This device go to this agent """ agent_to_id.comment = """ This device go to this agent """
action_id = Column(UUID(as_uuid=True),
ForeignKey(Action.id),
nullable=True)
action = relationship(Action,
backref=backref('actions_id', lazy=True, **_sorted_actions),
primaryjoin=action_id == Action.id)
action_id.comment = """ This Receive confirm this action """
class Migrate(JoinedTableMixin, ActionWithMultipleDevices): class Migrate(JoinedTableMixin, ActionWithMultipleDevices):

View file

@ -530,11 +530,9 @@ class TransferOwnershipBlockchain(Trade):
class Receive(ActionWithMultipleDevices): class Receive(ActionWithMultipleDevices):
role = ... # type:Column agent_from = ... # type: relationship
agent_to = ... # type: relationship
def __init__(self, **kwargs) -> None: action = ... # type: relationship
super().__init__(**kwargs)
self.role = ... # type: ReceiverRole
class Migrate(ActionWithMultipleDevices): class Migrate(ActionWithMultipleDevices):