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
This commit is contained in:
parent
f06a4ecbfa
commit
2f5a258582
@ -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')
|
||||
|
@ -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"),
|
||||
|
@ -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)
|
||||
|
@ -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'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user