{% extends "crud/form.html" %} {% from "macros/form.html" import text_input, number_input, select, checkbox_list, readonly_field %} {% set title = 'Edit Key' if is_update else 'Create Key' %} {# One dialog for every case -- same title, same footer, same "Confirm" button in the same place -- so deleting a key always looks like the same action; only the body (and what Confirm does) changes with server_count and migration_targets. #} {% set delete_dialog = 'deleteKeyModal' if is_update else '' %} {% block form_fields %} {% if is_update %} {{ readonly_field('Key', key.key, help='Key identifier cannot be changed') }} {% else %} {{ text_input('key', 'Key', value='', help='Leave empty to auto-generate a unique key', maxlength=key_max_length) }} {% endif %} {{ text_input('note', 'Description', value=(key.note or '') if key else '', maxlength=256) }} {{ number_input('server_limit', 'Server Limit', value=key.server_limit if key else 0, help='Maximum number of servers (0 = unlimited)', min=0) }} {{ select('feed', 'Feed', options=feeds, selected=key.feed if key else default_feed) }} {{ checkbox_list('products', 'Products', options=products, selected=key.products_list if key and key.products_list else [], help='Select which products this key can use') }} {% endblock %} {% block page_modals %} {{ super() }} {% if delete_dialog %} {# `url_for` rather than `request.path`, which is already decoded, so a key named with `?`, `#` or `%` posts to its own delete. #} {% set delete_action = url_for('admin_crud.keys_delete_confirm', key=key.key) %} {% set servers = server_count ~ ' server' ~ ('s' if server_count != 1 else '') %} {% set them = 'it' if server_count == 1 else 'them' %}
{% endif %} {% endblock %} {% block page_scripts %} {{ super() }} {% if delete_dialog %} {% endif %} {% endblock %}