File tree Expand file tree Collapse file tree 3 files changed +14
-12
lines changed Expand file tree Collapse file tree 3 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 52
52
# - Third Item
53
53
# - Fifth Item
54
54
# - Fourth Item
55
- # select_field_auto_weight :
55
+ # select_field_legacy_format :
56
56
# type: select
57
57
# label: Choose between items
58
58
# required: false
61
61
# on_objects:
62
62
# - dcim.models.Device
63
63
# choices:
64
- # - A
65
- # - B
66
- # - C
67
- # - E
68
- # - D like deprecated
64
+ # - value: A # this is the deprecated format.
65
+ # - value: B # we only use it for the tests.
66
+ # - value: C # please see above for the new format.
67
+ # - value: "D like deprecated"
68
+ # weight: 999
69
+ # - value: E
69
70
# boolean_field:
70
71
# type: boolean
71
72
# label: Yes Or No?
Original file line number Diff line number Diff line change 1
1
import sys
2
2
3
- from django .contrib .auth .models import Group , User
3
+ from django .contrib .auth .models import User
4
4
from startup_script_utils import load_yaml , set_permissions
5
5
from users .models import Token
6
6
Original file line number Diff line number Diff line change @@ -45,12 +45,13 @@ def get_class_for_class_path(class_path):
45
45
if cf_details .get ('choices' , False ):
46
46
custom_field .choices = []
47
47
48
- for choice_detail in enumerate (cf_details .get ('choices' , [])):
49
- if isinstance (choice_detail , str ):
50
- custom_field .choices .append (choice_detail )
51
- else : # legacy mode
52
- print (f"⚠️ Please migrate the 'choices' of '{ cf_name } ' to the new format, as 'weight' is no longer supported!" )
48
+ for choice_detail in cf_details .get ('choices' , []):
49
+ if isinstance (choice_detail , dict ) and 'value' in choice_detail :
50
+ # legacy mode
51
+ print (f"⚠️ Please migrate the choice '{ choice_detail ['value' ]} ' of '{ cf_name } ' to the new format, as 'weight' is no longer supported!" )
53
52
custom_field .choices .append (choice_detail ['value' ])
53
+ else :
54
+ custom_field .choices .append (choice_detail )
54
55
55
56
custom_field .save ()
56
57
You can’t perform that action at this time.
0 commit comments