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']: