Skip to content

Commit

Permalink
Fix single reference as dict (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
parayacr authored Aug 1, 2022
1 parent d88c3e5 commit 4ab66b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions swimlane/core/fields/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"""
Expand Down
4 changes: 2 additions & 2 deletions tests/fields/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4ab66b9

Please sign in to comment.