Skip to content

Commit

Permalink
lintfix
Browse files Browse the repository at this point in the history
  • Loading branch information
batpad committed Sep 2, 2023
1 parent 9397c05 commit f262981
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
72 changes: 36 additions & 36 deletions kubespawner/templates/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,48 @@ <h3>{{ profile.display_name }}</h3>
<div class="js-options-container">
<div class="option">
{%- if option['choices'] %}
<label for="profile-option-{{ profile.slug }}--{{ k }}"
class="js-profile-option-label">{{ option.display_name }}</label>
<select name="profile-option-{{ profile.slug }}--{{ k }}"
class="form-control js-profile-option-select">
{%- for k, choice in option['choices'].items() %}
<option value="{{ k }}" {% if choice.default %}selected{% endif %}>{{ choice.display_name }}</option>
{%- endfor %}
{%- if option['unlisted_choice']['enabled'] %}
<option value="unlisted-choice">{{ option['unlisted_choice']['display_name_in_choices'] }}</option>
{%- endif %}
</select>
<label for="profile-option-{{ profile.slug }}--{{ k }}"
class="js-profile-option-label">{{ option.display_name }}</label>
<select name="profile-option-{{ profile.slug }}--{{ k }}"
class="form-control js-profile-option-select">
{%- for k, choice in option['choices'].items() %}
<option value="{{ k }}" {% if choice.default %}selected{% endif %}>{{ choice.display_name }}</option>
{%- endfor %}
{%- if option['unlisted_choice']['enabled'] %}
<option value="unlisted-choice">{{ option['unlisted_choice']['display_name_in_choices'] }}</option>
{%- endif %}
</select>
{%- endif %}
</div>
{%- if option['unlisted_choice']['enabled'] %}
<div class="option js-other-input-container {%- if option['choices'] %} hidden {%- endif %}">
<div class="option js-other-input-container {%- if option['choices'] %}hidden{%- endif %}">
<label for="profile-option-{{ profile.slug }}--{{ k }}--unlisted-choice">
{{ option['unlisted_choice']['display_name'] }}
</label>
<input
{#- FIXME: This has gotten a bit ugly, ideally we would handle a lot of this
<input
{#- FIXME: This has gotten a bit ugly, ideally we would handle a lot of this
logic all in Javascript and not need this conditional attribute rendering #}
{%- if option['choices'] %}
data-name="profile-option-{{ profile.slug }}--{{ k }}--unlisted-choice"
{%- else %}
name="profile-option-{{ profile.slug }}--{{ k }}--unlisted-choice"
{%- endif %}
{%- if option['unlisted_choice']['validation_regex'] %}
pattern="{{ option['unlisted_choice']['validation_regex'] }}"
{%- endif %}
title="{{ option['unlisted_choice']['validation_message'] }}"
class="form-control js-other-input" />
</div>
{%- endif %}
</div>
{%- endfor %}
</div>
{%- endif %}
</div>
</label>
{%- endfor %}
</div>
<script>
{%- if option['choices'] %}
data-name="profile-option-{{ profile.slug }}--{{ k }}--unlisted-choice"
{%- else %}
name="profile-option-{{ profile.slug }}--{{ k }}--unlisted-choice"
{%- endif %}
{%- if option['unlisted_choice']['validation_regex'] %}
pattern="{{ option['unlisted_choice']['validation_regex'] }}"
{%- endif %}
title="{{ option['unlisted_choice']['validation_message'] }}"
class="form-control js-other-input" />
</div>
{%- endif %}
</div>
{%- endfor %}
</div>
{%- endif %}
</div>
</label>
{%- endfor %}
</div>
<script>
$('.js-profile-option-select, .js-profile-option-label').click(function() {
// we need this bit of JS to select the profile when a <select> inside is clicked.
$(this).parents('.js-profile-label')
Expand Down Expand Up @@ -104,4 +104,4 @@ <h3>{{ profile.display_name }}</h3>
$('.js-profile-option-select').trigger('change');
});

</script>
</script>
3 changes: 2 additions & 1 deletion tests/test_spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ async def test_expansion_hyphens():
'enabled': True,
'display_name': 'Image Location',
'kubespawner_override': {'image': '{value}'},
}
},
},
},
},
Expand Down Expand Up @@ -1122,6 +1122,7 @@ async def test_user_options_set_from_form_no_regex():
await spawner.load_user_options()
assert getattr(spawner, 'image') == 'invalid/foo:latest'


async def test_user_options_unlisted_choice_without_choices():
"""
Test that if a profile does not have `choices` but has an unlisted_choice definition,
Expand Down

0 comments on commit f262981

Please sign in to comment.