From f77439f39880fb64d9a585d06fbef5f9457d158c Mon Sep 17 00:00:00 2001 From: catborise Date: Sat, 31 Oct 2026 18:05:34 +0300 Subject: [PATCH] fix(storages): a refused new volume comes back in its dialog A New volume form the pool page refused, for a name with a space or a character not allowed, redirected back with the reasons at the top of the page and lost what was typed. The form now posts to the pool page itself: a valid one makes the volume and redirects as before, a refused one renders the page with the dialog open on what was entered, the refused field marked with its reason and focused. A pool stopped meanwhile has no dialog: its page shows the reasons. The separate create_volume view and URL go. --- computes/urls.py | 7 +- instances/tests/test_views.py | 24 ------- storages/templates/create_stg_vol_block.html | 7 +- storages/templates/storage.html | 7 ++ storages/tests/test_audit_rows.py | 3 +- storages/tests/test_pool_page.py | 28 ++++++++ storages/views.py | 68 +++++++------------- 7 files changed, 63 insertions(+), 81 deletions(-) diff --git a/computes/urls.py b/computes/urls.py index 36b8ce80..37647d2e 100644 --- a/computes/urls.py +++ b/computes/urls.py @@ -6,7 +6,7 @@ from interfaces.views import interface, interfaces from networks.views import network, networks from nodedevs.views import nodedevs from nwfilters.views import nwfilter, nwfilters -from storages.views import create_volume, get_volumes, storage, storages +from storages.views import get_volumes, storage, storages from . import forms, views @@ -66,11 +66,6 @@ urlpatterns = [ path("storages/", storages, name="storages"), path("storage//volumes/", get_volumes, name="volumes"), path("storage//", storage, name="storage"), - path( - "storage//create_volume/", - create_volume, - name="create_volume", - ), path("networks/", networks, name="networks"), path("network//", network, name="network"), path("interfaces/", interfaces, name="interfaces"), diff --git a/instances/tests/test_views.py b/instances/tests/test_views.py index 63a76c3d..5d8b3952 100644 --- a/instances/tests/test_views.py +++ b/instances/tests/test_views.py @@ -153,18 +153,6 @@ class InstancesTestCase(TestCase): ) self.assertRaises(Http404) - # def test_create_volume(self): - # response = self.client.post( - # reverse('create_volume', args=[self.compute.id, 'default']), - # { - # 'name': 'test', - # 'format': 'qcow2', - # 'size': '1', - # 'meta_prealloc': False, - # }, - # ) - # self.assertRedirects(response, reverse('storage', args=[self.compute.id, 'default'])) - def test_create_destroy_instance(self): # Create response = self.client.get( @@ -1126,18 +1114,6 @@ class InstancesTestCase(TestCase): # del self.instance.status # self.assertEqual(self.instance.status, 1) - # # create volume - # response = self.client.post( - # reverse('create_volume', args=[compute.id, 'default']), - # { - # 'name': 'test3', - # 'format': 'qcow2', - # 'size': '1', - # 'meta_prealloc': False, - # }, - # ) - # self.assertRedirects(response, reverse('storage', args=[compute.id, 'default'])) - # # delete volume # response = self.client.post( # reverse('instances:delete_vol', args=[instance.id]), diff --git a/storages/templates/create_stg_vol_block.html b/storages/templates/create_stg_vol_block.html index 0e37624e..af2b1295 100644 --- a/storages/templates/create_stg_vol_block.html +++ b/storages/templates/create_stg_vol_block.html @@ -41,7 +41,8 @@ {% trans "New volume" %} -