Browse Source

Modify the error message when creating subnet

The error message is incorrect:
'Specify "Network Address" or clear "Create Subnet" checkbox in previous step'
on create subnet page, It has no previous step

Change-Id: Ib91c29d8de7f75744f38bd624234e6f2416673e1
Closes-Bug: #1812157
pengyuesheng 3 months ago
parent
commit
4624438f17

+ 3
- 2
openstack_dashboard/dashboards/project/networks/subnets/workflows.py View File

@@ -41,7 +41,7 @@ class CreateSubnetInfoAction(network_workflows.CreateSubnetInfoAction):
41 41
 
42 42
     def clean(self):
43 43
         cleaned_data = workflows.Action.clean(self)
44
-        self._check_subnet_data(cleaned_data)
44
+        self._check_subnet_data(cleaned_data, with_network_form=False)
45 45
         return cleaned_data
46 46
 
47 47
 
@@ -114,7 +114,8 @@ class UpdateSubnetInfoAction(CreateSubnetInfoAction):
114 114
 
115 115
     def clean(self):
116 116
         cleaned_data = workflows.Action.clean(self)
117
-        self._check_subnet_data(cleaned_data, is_create=False)
117
+        self._check_subnet_data(cleaned_data, is_create=False,
118
+                                with_network_form=False)
118 119
         return cleaned_data
119 120
 
120 121
 

+ 7
- 3
openstack_dashboard/dashboards/project/networks/workflows.py View File

@@ -279,7 +279,8 @@ class CreateSubnetInfoAction(workflows.Action):
279 279
                         'allowed': range_str})
280 280
                 raise forms.ValidationError(msg)
281 281
 
282
-    def _check_subnet_data(self, cleaned_data, is_create=True):
282
+    def _check_subnet_data(self, cleaned_data, is_create=True,
283
+                           with_network_form=True):
283 284
         cidr = cleaned_data.get('cidr')
284 285
         ip_version = int(cleaned_data.get('ip_version'))
285 286
         gateway_ip = cleaned_data.get('gateway_ip')
@@ -293,8 +294,11 @@ class CreateSubnetInfoAction(workflows.Action):
293 294
                     '"Network Address".')
294 295
             raise forms.ValidationError(msg)
295 296
         if not cidr and address_source != 'subnetpool':
296
-            msg = _('Specify "Network Address" or '
297
-                    'clear "Create Subnet" checkbox in previous step.')
297
+            if with_network_form:
298
+                msg = _('Specify "Network Address" or '
299
+                        'clear "Create Subnet" checkbox in previous step.')
300
+            else:
301
+                msg = _("Specify network address")
298 302
             raise forms.ValidationError(msg)
299 303
         if cidr:
300 304
             subnet = netaddr.IPNetwork(cidr)

Loading…
Cancel
Save