Set False to include_empty_option
In _populate_custom_choices(), all methods called at the method have
True as a second argument. It means that the default values sepcified
in a stack are not shown as default when launch stack form.
The fileds always show 'Select Flavor/Image/Network'.
Users doesn't expect to choose default value by hand.
This change shows the default values defined at a template.
Also, image_field_data() doesn't use parameter, include_empty_option.
This change modfies the method to change the behavior based on the
parameter.
Closes-Bug: #1619465
Change-Id: I4b6bef322a668a805abcd4bc472d30f6d1df3a0a
(cherry picked from commit 792f8cbe4a
)
This commit is contained in:
parent
c8c965a8eb
commit
81190f1b0d
|
@ -55,7 +55,7 @@ def image_field_data(request, include_empty_option=False):
|
|||
except Exception:
|
||||
exceptions.handle(request, _('Unable to retrieve images'))
|
||||
images.sort(key=lambda c: c.name)
|
||||
images_list = [('', _('Select Image'))]
|
||||
images_list = []
|
||||
for image in images:
|
||||
image_label = u"{} ({})".format(image.name, filesizeformat(image.size))
|
||||
images_list.append((image.id, image_label))
|
||||
|
@ -63,6 +63,9 @@ def image_field_data(request, include_empty_option=False):
|
|||
if not images:
|
||||
return [("", _("No images available")), ]
|
||||
|
||||
if include_empty_option:
|
||||
return [("", _("Select Image")), ] + images_list
|
||||
|
||||
return images_list
|
||||
|
||||
|
||||
|
@ -443,13 +446,13 @@ class CreateStackForm(forms.SelfHandlingForm):
|
|||
|
||||
def _populate_custom_choices(self, custom_type):
|
||||
if custom_type == 'neutron.network':
|
||||
return instance_utils.network_field_data(self.request, True)
|
||||
return instance_utils.network_field_data(self.request, False)
|
||||
if custom_type == 'nova.keypair':
|
||||
return instance_utils.keypair_field_data(self.request, True)
|
||||
return instance_utils.keypair_field_data(self.request, False)
|
||||
if custom_type == 'glance.image':
|
||||
return image_field_data(self.request, True)
|
||||
return image_field_data(self.request, False)
|
||||
if custom_type == 'nova.flavor':
|
||||
return instance_utils.flavor_field_data(self.request, True)
|
||||
return instance_utils.flavor_field_data(self.request, False)
|
||||
return []
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue