fixing bug for documents

This commit is contained in:
Cayo Puigdefabregas 2021-11-08 17:33:22 +01:00
parent f8be48d524
commit c7ced04e9d
1 changed files with 17 additions and 5 deletions

View File

@ -233,9 +233,9 @@ class TradeMetrics(MetricsMix):
row['status_receiver'] = '' row['status_receiver'] = ''
row['status_supplier'] = '' row['status_supplier'] = ''
row['trade_weight'] = self.document.weight row['trade_weight'] = self.document.weight
if self.last_trade.author == self.last_trade.user_from: if self.document.owner == self.last_trade.user_from:
row['action_create_by'] = 'Supplier' row['action_create_by'] = 'Supplier'
elif self.last_trade.author == self.last_trade.user_to: elif self.document.owner == self.last_trade.user_to:
row['action_create_by'] = 'Receiver' row['action_create_by'] = 'Receiver'
self.rows.append(row) self.rows.append(row)
@ -247,8 +247,20 @@ class TradeMetrics(MetricsMix):
if the action is one trade action, is possible than have a list of confirmations. if the action is one trade action, is possible than have a list of confirmations.
Get the doble confirm for to know if this trade is confirmed or not. Get the doble confirm for to know if this trade is confirmed or not.
""" """
if hasattr(self.last_trade, 'acceptances_document'): trade = None
accept = self.last_trade.acceptances_document[-1] confirmations = []
if accept.t == 'Confirm' and accept.user == self.last_trade.user_to: confirms = []
for ac in self.document.actions:
if ac.t == 'Trade':
trade = ac
elif ac.t == 'ConfirmDocument':
confirms.append(ac.author)
confirmations.append(ac)
elif ac.t in ['RevokeDocument', 'ConfirmDocumentRevoke']:
confirmations.append(ac)
if confirmations and confirmations[-1].t == 'ConfirmDocument':
if trade.user_from in confirms and trade.user_to in confirms:
return True return True
return False return False