From 7955baf35c46515e6b845d6805b3d8b55f0eb27d Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Mon, 5 Feb 2024 12:07:35 +0100 Subject: views: preselect pxe boot mode in add client preselect 'pxe' (if available) at adding a new client. use a dedicated template for adding a client and remove irrelevant partition table; client has yet to set its partition, so everytime, the table would load empty. --- ogcp/templates/actions/client_add.html | 19 +++++++++++++++++++ ogcp/views.py | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 ogcp/templates/actions/client_add.html diff --git a/ogcp/templates/actions/client_add.html b/ogcp/templates/actions/client_add.html new file mode 100644 index 0000000..b1c37a5 --- /dev/null +++ b/ogcp/templates/actions/client_add.html @@ -0,0 +1,19 @@ +{% extends parent %} +{% import "bootstrap/wtf.html" as wtf %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block nav_client %} active{% endblock %} +{% block nav_client_details %} active{% endblock %} +{% block nav_client_add %}active{% endblock %} +{% block content %} + +

{{_('Add client')}}

+ +{{ wtf.quick_form(form, + method='post', + button_map={'submit': 'primary'}, + extra_classes="mx-5") }} + +{% endblock %} diff --git a/ogcp/views.py b/ogcp/views.py index 572b784..8f94cad 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1312,7 +1312,9 @@ def action_client_add(): if r.status_code != requests.codes.ok: return ogserver_error('scopes') - available_modes = [(mode, mode) for mode in r.json()['modes']] + available_modes = [(mode, mode) for mode in r.json()['modes'] if mode == 'pxe'] + available_modes.extend([(mode, mode) for mode in r.json()['modes'] if mode != 'pxe']) + form.boot.choices = list(available_modes) form.mac.render_kw = {'placeholder': 'aabbccddeeaa'} @@ -1344,7 +1346,7 @@ def action_client_add(): form.submit.render_kw = {"formaction": url_for('action_client_add')} scopes, clients = get_scopes() - return render_template('actions/client_details.html', form=form, + return render_template('actions/client_add.html', form=form, parent="scopes.html", scopes=scopes) PLACEHOLDER_TEXT = '''host example1 { hardware ethernet 94:c6:91:a6:25:1a; fixed-address 10.141.10.100; } -- cgit v1.2.3-18-g5258