Fix custom fields initializer
This commit is contained in:
parent
234baa40a5
commit
e383fd42bd
3 changed files with 14 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
import sys
|
||||
|
||||
from django.contrib.auth.models import Group, User
|
||||
from django.contrib.auth.models import User
|
||||
from startup_script_utils import load_yaml, set_permissions
|
||||
from users.models import Token
|
||||
|
||||
|
|
|
@ -45,12 +45,13 @@ for cf_name, cf_details in customfields.items():
|
|||
if cf_details.get('choices', False):
|
||||
custom_field.choices = []
|
||||
|
||||
for choice_detail in enumerate(cf_details.get('choices', [])):
|
||||
if isinstance(choice_detail, str):
|
||||
custom_field.choices.append(choice_detail)
|
||||
else: # legacy mode
|
||||
print(f"⚠️ Please migrate the 'choices' of '{cf_name}' to the new format, as 'weight' is no longer supported!")
|
||||
for choice_detail in cf_details.get('choices', []):
|
||||
if isinstance(choice_detail, dict) and 'value' in choice_detail:
|
||||
# legacy mode
|
||||
print(f"⚠️ Please migrate the choice '{choice_detail['value']}' of '{cf_name}' to the new format, as 'weight' is no longer supported!")
|
||||
custom_field.choices.append(choice_detail['value'])
|
||||
else:
|
||||
custom_field.choices.append(choice_detail)
|
||||
|
||||
custom_field.save()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue