diff --git a/console/templates/console-vnc-full.html b/console/templates/console-vnc-full.html index 0036fcb4..f69113a6 100755 --- a/console/templates/console-vnc-full.html +++ b/console/templates/console-vnc-full.html @@ -345,7 +345,7 @@
{% if perms.instances.passwordless_console %} - + {% else %} {% endif %} diff --git a/instances/forms.py b/instances/forms.py index 8de34f97..ba9247e3 100644 --- a/instances/forms.py +++ b/instances/forms.py @@ -30,7 +30,6 @@ class ConsoleForm(forms.Form): widget=forms.PasswordInput(render_value=True), required=False ) - clear_keymap = forms.BooleanField(label=_("Clear keymap"), required=False) keymap = forms.ChoiceField(label=_("Keymap"), required=False) def __init__(self, *args, instance, can_set_listener, **kwargs): diff --git a/instances/templates/instances/access_tab.html b/instances/templates/instances/access_tab.html index 63d04700..2c7f5e0e 100644 --- a/instances/templates/instances/access_tab.html +++ b/instances/templates/instances/access_tab.html @@ -60,7 +60,7 @@ - +
{% endif %} {% if instance.status == 1 %} diff --git a/instances/tests/test_vm_audit_rows.py b/instances/tests/test_vm_audit_rows.py index f3d20213..2ddf8b58 100644 --- a/instances/tests/test_vm_audit_rows.py +++ b/instances/tests/test_vm_audit_rows.py @@ -119,6 +119,17 @@ class VMRowTests(TestCase): self.assertEqual(self.rows(), [("VM vm: set console keymap de", True), ("VM vm: set console listen address 0.0.0.0", True)]) + def test_auto_removes_the_keymap(self): + # no "Clear keymap" box: Auto removes it, never writes an empty keymap + self.proxy.get_console_type.return_value = "vnc" + self.proxy.get_console_listener_addr.return_value = "127.0.0.1" + self.proxy.get_console_passwd.return_value = "" + self.proxy.get_console_keymap.return_value = "de" + self.proxy.set_console_keymap.return_value = None + self.post("update_console", {"listen_on": "127.0.0.1", "keymap": "auto"}) + self.proxy.set_console_keymap.assert_called_once_with("auto") + self.assertEqual(self.rows(), [("VM vm: remove console keymap", True)]) + def test_a_console_save_logs_only_what_changed(self): # an address the form does not list stays: the select offers it self.proxy.get_console_type.return_value = "vnc" diff --git a/instances/views.py b/instances/views.py index 149cc93d..33b41800 100755 --- a/instances/views.py +++ b/instances/views.py @@ -1979,10 +1979,11 @@ def update_console(request, pk): ) messages.error(request, msg) - if "keymap" in form.changed_data or "clear_keymap" in form.changed_data: - keymap = "" if form.cleaned_data["clear_keymap"] else form.cleaned_data["keymap"] + if "keymap" in form.changed_data: + # "auto" removes the keymap: the client's keys go through as they are + keymap = form.cleaned_data["keymap"] # False: no graphics device, nothing changed - with audit_vm(request, instance, f"set console keymap {keymap}" if keymap else "remove console keymap") as entry: + with audit_vm(request, instance, "remove console keymap" if keymap == "auto" else f"set console keymap {keymap}") as entry: entry.skip = instance.proxy.set_console_keymap(keymap) is False if "listen_on" in form.changed_data: