1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 19:56:48 +00:00

fix(admin): a default VM that is not exactly one VM is refused on the form

NEW_USER_DEFAULT_INSTANCES names VMs, and a name may repeat across hosts.
A name with no VM, or with one on two hosts, made creating any user a 500.
The create form now looks the names up and says which one is not exactly
one VM; the user and its default VMs are saved together.
This commit is contained in:
catborise 2026-10-26 10:51:05 +03:00
parent 2e5ef34473
commit addff12652
4 changed files with 47 additions and 21 deletions

View file

@ -1,7 +1,7 @@
"""Changes to users and groups write rows on the Logs page."""
from django.contrib.auth.models import Group, Permission, User
from django.test import TestCase, override_settings
from django.test import TestCase
from django.urls import reverse
from logs.models import Logs
@ -77,14 +77,6 @@ class UserRowTests(TestCase):
])
self.assertFalse(Logs.objects.filter(message__contains="New-carol-pass-1").exists())
@override_settings(NEW_USER_DEFAULT_INSTANCES=["no-such-vm"])
def test_a_failing_default_vm_leaves_no_user(self):
from instances.models import Instance
with self.assertRaises(Instance.DoesNotExist):
self.create()
self.assertFalse(User.objects.filter(username="carol").exists())
self.assertEqual(rows(), [("User carol: add: DoesNotExist", False)])
def test_the_row_has_actor_and_ip(self):
self.client.post(
reverse("admin:user_create"), {"username": "carol", "password": "Carol-pass-2026", **ATTRIBUTES},