fixing schema

This commit is contained in:
Cayo Puigdefabregas 2021-11-05 13:10:23 +01:00
parent 6bf1354109
commit f8be48d524
1 changed files with 9 additions and 3 deletions

View File

@ -439,7 +439,7 @@ class ActionStatus(Action):
@pre_load
def put_devices(self, data: dict):
if not 'devices' in data.keys():
if 'devices' not in data.keys():
data['devices'] = []
@post_load
@ -447,10 +447,16 @@ class ActionStatus(Action):
for dev in data['devices']:
if dev.trading in [None, 'Revoke', 'ConfirmRevoke']:
return data
trade = [ac for ac in dev.actions if ac.t == 'Trade'][-1]
trades = [ac for ac in dev.actions if ac.t == 'Trade']
if not trades:
return data
trade = trades[-1]
if trade.user_to != g.user:
data['rol_user'] = trade.user_to
data['trade'] = trade
data['trade'] = trade
class Recycling(ActionStatus):