diff --git a/kubespawner/spawner.py b/kubespawner/spawner.py index c92f66e73..59c041f61 100644 --- a/kubespawner/spawner.py +++ b/kubespawner/spawner.py @@ -794,34 +794,34 @@ def _hub_connect_port_default(self): ) form_template = Unicode( - """ + """ """, config = True, - help = """Template to use to construct options_form text. {input_template} is replaced with - the result of formatting input_template against each item in the profiles list.""" + help = """Template to use to construct options_form text. {inputs} is replaced with + the result of formatting inputs against each item in the profiles list.""" ) - input_template = Unicode(""" + inputs = Unicode(""" """, config = True, - help = """Template to construct {input_template} in form_template. This text will be formatted + help = """Template to construct {inputs} in form_template. This text will be formatted against each item in the profiles list, in order, using the following key names: ( display, key, type ) for the first three items in the tuple, and additionally - first = "checked" (taken from first_template) for the first item in the list, so that + first = "checked" (taken from first_input) for the first item in the list, so that the first item starts selected.""" ) - first_template = Unicode('selected', + first_input = Unicode('selected', config=True, - help="Text to substitute as {first} in input_template" + help="Text to substitute as {first} in inputs" ) options_form = Unicode() - single_user_profile_list = List( + profile_list = List( trait = Dict(), default_value = None, minlen = 0, @@ -1147,24 +1147,24 @@ def get_args(self): return args def _options_form_default(self): - if not self.single_user_profile_list: + if not self.profile_list: return temp_keys = [ { 'display': p.get('display_name', self.UNDEFINED_DISPLAY_NAME), 'key': i, 'first': '', - } for i, p in enumerate(self.single_user_profile_list)] - temp_keys[0]['first'] = self.first_template - text = ''.join([ self.input_template.format(**tk) for tk in temp_keys ]) - return self.form_template.format(input_template=text) + } for i, p in enumerate(self.profile_list)] + temp_keys[0]['first'] = self.first_input + text = ''.join([ self.inputs.format(**tk) for tk in temp_keys ]) + return self.form_template.format(inputs=text) def options_from_form(self, formdata): - if not self.single_user_profile_list: + if not self.profile_list: return form_data # Default to first profile if somehow none is provided selected_profile = int(formdata.get('profile',[0])[0]) - options = self.single_user_profile_list[selected_profile] + options = self.profile_list[selected_profile] self.log.debug("Applying KubeSpawner override for profile '%s'", options.get('display_name', self.UNDEFINED_DISPLAY_NAME)) kubespawner_override = options.get('kubespawner_override', {})