Skip to content

Commit

Permalink
Adding choices to serialzier for ChoiceFields
Browse files Browse the repository at this point in the history
  • Loading branch information
john-westcott-iv committed Jan 25, 2024
1 parent 72877cf commit ac5c207
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 12 additions & 10 deletions ansible_base/authentication/authenticator_plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ def get_configuration_schema(self):
if field.default is not empty:
default = field.default

schema.append(
{
"name": f,
"help_text": field.help_text,
"required": not field.allow_null,
"default": default,
"type": field.__class__.__name__,
"ui_field_label": getattr(field, 'ui_field_label', _('Undefined')),
}
)
schema_data = {
"name": f,
"help_text": field.help_text,
"required": not field.allow_null,
"default": default,
"type": field.__class__.__name__,
"ui_field_label": getattr(field, 'ui_field_label', _('Undefined')),
}
if getattr(field, 'choices', None):
schema_data["choices"] = getattr(field, 'choices')

schema.append(schema_data)
return schema


Expand Down
2 changes: 0 additions & 2 deletions ansible_base/lib/serializers/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def __init__(self, **kwargs):

class ChoiceField(UILabelMixIn, serializers.ChoiceField):
def __init__(self, **kwargs):
# TODO: SEE IF THIS WORKS FOR KEITH on the authenticator_plugin page see if its now shows options for the choice fields.
self.ui_field_label = kwargs.pop('ui_field_label', 'Undefined')
super().__init__(**kwargs)


Expand Down

0 comments on commit ac5c207

Please sign in to comment.