From 6599f4b66c524b4b2506f194a9186f4ddaf9a1d8 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 1 Oct 2021 10:46:08 +0200 Subject: [PATCH] fixing bug --- .../versions/a0978ac6cf4a_adding_state_actions.py | 2 +- ereuse_devicehub/resources/action/schemas.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/a0978ac6cf4a_adding_state_actions.py b/ereuse_devicehub/migrations/versions/a0978ac6cf4a_adding_state_actions.py index 02422946..963611ad 100644 --- a/ereuse_devicehub/migrations/versions/a0978ac6cf4a_adding_state_actions.py +++ b/ereuse_devicehub/migrations/versions/a0978ac6cf4a_adding_state_actions.py @@ -12,7 +12,7 @@ from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = 'a0978ac6cf4a' -down_revision = '7ecb8ff7abad' +down_revision = '3ac2bc1897ce' branch_labels = None depends_on = None diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index 3dc22160..c8e06b75 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -424,14 +424,24 @@ class Ready(ActionWithMultipleDevices): __doc__ = m.Ready.__doc__ -class ActionStatus(ActionWithMultipleDevices): +class ActionStatus(Action): rol_user = NestedOn(s_user.User, dump_only=True, exclude=('token',)) + devices = NestedOn(s_device.Device, + many=True, + required=False, # todo test ensuring len(devices) >= 1 + only_query='id', + collection_class=OrderedSet) documents = NestedOn(s_document.TradeDocument, many=True, required=False, # todo test ensuring len(devices) >= 1 only_query='id', collection_class=OrderedSet) + @pre_load + def put_devices(self, data: dict): + if not 'devices' in data.keys(): + data['devices'] = [] + @post_load def put_rol_user(self, data: dict): for dev in data['devices']: