adding trade in status actions
This commit is contained in:
parent
56df40c81a
commit
5ebf4f48b5
|
@ -49,8 +49,21 @@ def upgrade():
|
|||
nullable=False, comment='When Devicehub created this.'),
|
||||
schema=f'{get_inv()}')
|
||||
|
||||
op.add_column('action_status',
|
||||
sa.Column('trade_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
schema=f'{get_inv()}')
|
||||
|
||||
op.create_foreign_key("fk_action_status_trade",
|
||||
"action_status", "trade",
|
||||
["trade_id"], ["id"],
|
||||
ondelete="SET NULL",
|
||||
source_schema=f'{get_inv()}',
|
||||
referent_schema=f'{get_inv()}')
|
||||
|
||||
upgrade_data()
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint("fk_action_status_trade", "action_status", type_="foreignkey", schema=f'{get_inv()}')
|
||||
op.drop_column('action_device', 'created', schema=f'{get_inv()}')
|
||||
op.drop_column('action_status', 'trade_id', schema=f'{get_inv()}')
|
||||
|
|
|
@ -1377,6 +1377,16 @@ class ActionStatus(JoinedTableMixin, ActionWithMultipleTradeDocuments):
|
|||
default=lambda: g.user.id)
|
||||
rol_user = db.relationship(User, primaryjoin=rol_user_id == User.id)
|
||||
rol_user_comment = """The user that ."""
|
||||
trade_id = db.Column(UUID(as_uuid=True),
|
||||
db.ForeignKey('trade.id'),
|
||||
nullable=True)
|
||||
trade = db.relationship('Trade',
|
||||
backref=backref('status_changes',
|
||||
uselist=True,
|
||||
lazy=True,
|
||||
order_by=lambda: Action.end_time,
|
||||
collection_class=list),
|
||||
primaryjoin='ActionStatus.trade_id == Trade.id')
|
||||
|
||||
|
||||
class Recycling(ActionStatus):
|
||||
|
|
|
@ -450,6 +450,7 @@ class ActionStatus(Action):
|
|||
trade = [ac for ac in dev.actions if ac.t == 'Trade'][-1]
|
||||
if trade.user_to != g.user:
|
||||
data['rol_user'] = trade.user_to
|
||||
data['trade'] = trade
|
||||
|
||||
|
||||
class Recycling(ActionStatus):
|
||||
|
|
|
@ -77,7 +77,6 @@ class Metrics(MetricsMix):
|
|||
self.rows.append(row)
|
||||
return
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
if self.last_trade['trade_supplier'] == self.act.author.email:
|
||||
self.last_trade['status_supplier'] = self.act.type
|
||||
self.last_trade['status_supplier_created'] = self.act.created
|
||||
|
@ -88,6 +87,10 @@ class Metrics(MetricsMix):
|
|||
self.last_trade['status_receiver_created'] = self.act.created
|
||||
return
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
# necesitamos poder poner un cambio de estado de un trade mas antiguo que last_trade
|
||||
# lo mismo con confirm
|
||||
|
||||
def get_snapshot(self):
|
||||
"""
|
||||
If there are one snapshot get the last lifetime for to do a calcul of time of use.
|
||||
|
@ -164,7 +167,9 @@ class Metrics(MetricsMix):
|
|||
row['status_receiver'] = self.status_receiver
|
||||
row['status_supplier'] = ''
|
||||
row['trade_confirmed'] = self.get_confirms()
|
||||
self.trades[self.act.created] = row
|
||||
# import pdb; pdb.set_trace()
|
||||
created = self.act.actions_device[0].created
|
||||
self.trades[created] = row
|
||||
self.rows.append(row)
|
||||
|
||||
def get_metrics(self):
|
||||
|
|
Reference in a new issue