From 2f5a2585827a281f086c8a94e1da497e0821f701 Mon Sep 17 00:00:00 2001 From: Ying Zuo Date: Fri, 7 Oct 2016 13:40:27 -0700 Subject: [PATCH] Fix issues on create network and create port modals Only delete the error for required field when segmentation id is not required for the network provider. Set string values as the choices for admin state field. Change-Id: Ie5d62960b85b9a1b9e0caf8fa51761d950cf430b Closes-bug: #1630416 --- openstack_dashboard/dashboards/admin/networks/forms.py | 9 +++++---- .../dashboards/admin/networks/ports/forms.py | 4 ++-- openstack_dashboard/dashboards/project/networks/forms.py | 4 ++-- .../dashboards/project/networks/ports/forms.py | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py index 41774a763..e57575ef3 100644 --- a/openstack_dashboard/dashboards/admin/networks/forms.py +++ b/openstack_dashboard/dashboards/admin/networks/forms.py @@ -126,8 +126,8 @@ class CreateNetwork(forms.SelfHandlingForm): 'data-switch-on': 'network_type', })) admin_state = forms.ThemableChoiceField( - choices=[(True, _('UP')), - (False, _('DOWN'))], + choices=[('True', _('UP')), + ('False', _('DOWN'))], label=_("Admin State")) shared = forms.BooleanField(label=_("Shared"), initial=False, required=False) @@ -288,9 +288,10 @@ class CreateNetwork(forms.SelfHandlingForm): def _clean_segmentation_id(self, data): network_type = data.get('network_type') if 'segmentation_id' in self._errors: - if network_type not in self.nettypes_with_seg_id: + if (network_type not in self.nettypes_with_seg_id and + not self.data.get("segmentation_id")): # In this case the segmentation ID is not required, so we can - # ignore any errors. + # ignore the field is required error. del self._errors['segmentation_id'] elif network_type in self.nettypes_with_seg_id: seg_id = data.get('segmentation_id') diff --git a/openstack_dashboard/dashboards/admin/networks/ports/forms.py b/openstack_dashboard/dashboards/admin/networks/ports/forms.py index d60d1c9b0..521f37a96 100644 --- a/openstack_dashboard/dashboards/admin/networks/ports/forms.py +++ b/openstack_dashboard/dashboards/admin/networks/ports/forms.py @@ -43,8 +43,8 @@ class CreatePort(forms.SelfHandlingForm): name = forms.CharField(max_length=255, label=_("Name"), required=False) - admin_state = forms.ThemableChoiceField(choices=[(True, _('UP')), - (False, _('DOWN'))], + admin_state = forms.ThemableChoiceField(choices=[('True', _('UP')), + ('False', _('DOWN'))], label=_("Admin State")) device_id = forms.CharField(max_length=100, label=_("Device ID"), help_text=_("Device ID attached to the port"), diff --git a/openstack_dashboard/dashboards/project/networks/forms.py b/openstack_dashboard/dashboards/project/networks/forms.py index da4fcbcd6..767f37d9b 100644 --- a/openstack_dashboard/dashboards/project/networks/forms.py +++ b/openstack_dashboard/dashboards/project/networks/forms.py @@ -39,8 +39,8 @@ class UpdateNetwork(forms.SelfHandlingForm): widget=forms.TextInput( attrs={'readonly': 'readonly'})) admin_state = forms.ThemableChoiceField( - choices=[(True, _('UP')), - (False, _('DOWN'))], + choices=[('True', _('UP')), + ('False', _('DOWN'))], required=False, label=_("Admin State")) shared = forms.BooleanField(label=_("Shared"), required=False) diff --git a/openstack_dashboard/dashboards/project/networks/ports/forms.py b/openstack_dashboard/dashboards/project/networks/ports/forms.py index e907ccd4f..f373ab4a2 100644 --- a/openstack_dashboard/dashboards/project/networks/ports/forms.py +++ b/openstack_dashboard/dashboards/project/networks/ports/forms.py @@ -39,8 +39,8 @@ class UpdatePort(forms.SelfHandlingForm): label=_("Name"), required=False) admin_state = forms.ThemableChoiceField( - choices=[(True, _('UP')), - (False, _('DOWN'))], + choices=[('True', _('UP')), + ('False', _('DOWN'))], label=_("Admin State")) failure_url = 'horizon:project:networks:detail'