From 4624438f17a1b2e122233aae1b907260d942784f Mon Sep 17 00:00:00 2001 From: pengyuesheng Date: Thu, 17 Jan 2019 14:12:56 +0800 Subject: [PATCH] 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 --- .../dashboards/project/networks/subnets/workflows.py | 5 +++-- .../dashboards/project/networks/workflows.py | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py index 277648a90b..85ca977eb4 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py @@ -41,7 +41,7 @@ class CreateSubnetInfoAction(network_workflows.CreateSubnetInfoAction): def clean(self): cleaned_data = workflows.Action.clean(self) - self._check_subnet_data(cleaned_data) + self._check_subnet_data(cleaned_data, with_network_form=False) return cleaned_data @@ -114,7 +114,8 @@ class UpdateSubnetInfoAction(CreateSubnetInfoAction): def clean(self): cleaned_data = workflows.Action.clean(self) - self._check_subnet_data(cleaned_data, is_create=False) + self._check_subnet_data(cleaned_data, is_create=False, + with_network_form=False) return cleaned_data diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py index 8a9683c470..81e81ab915 100644 --- a/openstack_dashboard/dashboards/project/networks/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/workflows.py @@ -279,7 +279,8 @@ class CreateSubnetInfoAction(workflows.Action): 'allowed': range_str}) raise forms.ValidationError(msg) - def _check_subnet_data(self, cleaned_data, is_create=True): + def _check_subnet_data(self, cleaned_data, is_create=True, + with_network_form=True): cidr = cleaned_data.get('cidr') ip_version = int(cleaned_data.get('ip_version')) gateway_ip = cleaned_data.get('gateway_ip') @@ -293,8 +294,11 @@ class CreateSubnetInfoAction(workflows.Action): '"Network Address".') raise forms.ValidationError(msg) if not cidr and address_source != 'subnetpool': - msg = _('Specify "Network Address" or ' - 'clear "Create Subnet" checkbox in previous step.') + if with_network_form: + msg = _('Specify "Network Address" or ' + 'clear "Create Subnet" checkbox in previous step.') + else: + msg = _("Specify network address") raise forms.ValidationError(msg) if cidr: subnet = netaddr.IPNetwork(cidr)