From 4ab66b91e17ea8ed4c20b96f716d51d83567b94c Mon Sep 17 00:00:00 2001 From: Pablo Araya <61434099+parayacr@users.noreply.github.com> Date: Mon, 1 Aug 2022 12:35:54 -0600 Subject: [PATCH] Fix single reference as dict (#141) --- swimlane/core/fields/reference.py | 7 +------ tests/fields/test_reference.py | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/swimlane/core/fields/reference.py b/swimlane/core/fields/reference.py index 5baf9a21..d3fe5f80 100644 --- a/swimlane/core/fields/reference.py +++ b/swimlane/core/fields/reference.py @@ -98,11 +98,6 @@ def _set(self, value): def set_swimlane(self, value): """Store record ids in separate location for later use, but ignore initial value""" - # Move single record into list to be handled the same by cursor class - if not self.multiselect: - if value and not isinstance(value, list): - value = [value] - # Values come in as a list of record ids or None value = value or [] if isinstance(value, dict): @@ -146,7 +141,7 @@ def get_swimlane(self): value = super(ReferenceField, self).get_swimlane() if value: ids = list(value.keys()) - return ids if self.multiselect else ids[0] + return ids def get_item(self): """Return cursor if multi-select, direct value if single-select""" diff --git a/tests/fields/test_reference.py b/tests/fields/test_reference.py index 8f7a6d43..d5f052b2 100644 --- a/tests/fields/test_reference.py +++ b/tests/fields/test_reference.py @@ -38,9 +38,9 @@ def test_single_select(self, mock_swimlane, mock_record): assert mock_record._raw['values'][field.id] is None field.set_python(mock_record) - assert mock_record._raw['values'][field.id] == mock_record.id + assert mock_record._raw['values'][field.id] == [mock_record.id] - field.set_swimlane(mock_record.id) + field.set_swimlane([mock_record.id]) assert mock_record.id in field._value def test_empty_multi_select(self, mock_record):