13983 split array fields in CSV data for CustomFieldChoices

This commit is contained in:
Arthur 2023-12-07 13:08:58 -08:00
parent fe3f21105c
commit 686633f048

View File

@ -85,6 +85,17 @@ class CustomFieldChoiceSetImportForm(CSVModelForm):
'name', 'description', 'extra_choices', 'order_alphabetically', 'name', 'description', 'extra_choices', 'order_alphabetically',
) )
def clean_extra_choices(self):
if isinstance(self.cleaned_data['extra_choices'], list):
data = []
for line in self.cleaned_data['extra_choices']:
try:
value, label = line.split(':', maxsplit=1)
except ValueError:
value, label = line, line
data.append((value, label))
return data
class CustomLinkImportForm(CSVModelForm): class CustomLinkImportForm(CSVModelForm):
content_types = CSVMultipleContentTypeField( content_types = CSVMultipleContentTypeField(