1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(appsettings): the console and NIC settings say what they do

The four console settings (scale, view-only, resize session, clip
viewport) said "The console starts ...", but they set how a VNC console
starts; a serial console has none of them, and typed into a view-only
one. The NIC model setting said "default" was libvirt's choice, while
a new VM with "default" gets a VirtIO card. Their descriptions now say
so (migration 0025).
This commit is contained in:
catborise 2026-11-13 12:39:41 +03:00
parent 5a52bcf43e
commit f47b79b0ed
6 changed files with 74 additions and 1 deletions

View file

@ -0,0 +1,29 @@
from django.db import migrations
from django.utils.translation import gettext_noop as _
# what these settings do: the console ones apply to a VNC console only (a
# serial console has none of them), and a new VM's NIC model "default" is VirtIO
DESCRIPTIONS = {
"CONSOLE_SCALE": _("The VNC console starts scaled to its window"),
"CONSOLE_VIEW_ONLY": _("The VNC console starts view-only: no keyboard or mouse input"),
"CONSOLE_RESIZE_SESSION": _("The VNC console starts asking the guest to fit its screen to the window"),
"CONSOLE_CLIP_VIEWPORT": _("The VNC console starts clipped to its window, without scaling"),
"INSTANCE_NIC_DEFAULT_TYPE": _("Network card model chosen first for a new VM (default: VirtIO)"),
}
def describe(apps, schema_editor):
AppSettings = apps.get_model("appsettings", "AppSettings")
for setting in AppSettings.objects.using(schema_editor.connection.alias).filter(key__in=DESCRIPTIONS):
setting.description = DESCRIPTIONS[setting.key]
setting.save()
class Migration(migrations.Migration):
dependencies = [
("appsettings", "0024_log_retention_setting"),
]
operations = [
migrations.RunPython(describe, migrations.RunPython.noop),
]

View file

@ -71,13 +71,15 @@ class ChoicesFixTestCase(TestCase):
descriptions = importlib.import_module("appsettings.migrations.0021_setting_descriptions")
vnc_and_nic = importlib.import_module("appsettings.migrations.0025_vnc_console_and_nic_descriptions")
class DescriptionsTestCase(TestCase):
def test_every_setting_says_what_it_does_within_its_column(self):
limit = AppSettings._meta.get_field("description").max_length
removed = {"VIEW_INSTANCE_DETAIL_BOTTOM_BAR"} # by 0023
for key, text in descriptions.DESCRIPTIONS.items():
# as the last migration that describes a setting says
for key, text in {**descriptions.DESCRIPTIONS, **vnc_and_nic.DESCRIPTIONS}.items():
with self.subTest(key=key):
self.assertLessEqual(len(text), limit)
if key not in removed: