Skip to content

Commit f8f3e0c

Browse files
fix get_select_value_map
1 parent 43cad3d commit f8f3e0c

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

seatable_api/convert_airtable.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def get_value_map(self, airtable_rows):
223223

224224
def get_select_data(self, select_list):
225225
return {'options': [{
226-
'name': value,
226+
'name': str(value),
227227
'id': self.random_num_id(),
228228
'color': self.random_color(),
229229
'textColor': TEXT_COLOR,
@@ -355,20 +355,32 @@ def get_select_value_map(self, columns, airtable_rows):
355355
if column_name == '_id':
356356
continue
357357
column = columns.get(column_name)
358-
if not column:
358+
if not column or not value:
359359
continue
360360
column_type = ColumnTypes(column['type'])
361361
if column_type not in (ColumnTypes.SINGLE_SELECT, ColumnTypes.MULTIPLE_SELECT):
362362
continue
363363
if column_name not in select_value_map:
364364
select_value_map[column_name] = []
365-
if value is not None and value not in select_value_map[column_name]:
366-
select_value_map[column_name].append(value)
365+
items = []
366+
if isinstance(value, dict):
367+
items.append(value.get('name', '')) # collaborator
368+
elif isinstance(value, list):
369+
for item in value:
370+
if isinstance(item, dict):
371+
items.append(item.get('name', '')) # collaborator
372+
else:
373+
items.append(item)
374+
else:
375+
items.append(value)
376+
for item in items:
377+
if item not in select_value_map[column_name]:
378+
select_value_map[column_name].append(item)
367379
return select_value_map
368380

369381
def get_select_options(self, select_list):
370382
return [{
371-
'name': value,
383+
'name': str(value),
372384
'id': self.random_num_id(),
373385
'color': self.random_color(),
374386
'textColor': TEXT_COLOR,

0 commit comments

Comments
 (0)