Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds default text for keypair select widget on launch form.
Fixes bug 953488.

Change-Id: I089f281111203959995fb0ca5068cd2aabcd2b18
  • Loading branch information
gabrielhurley committed Mar 13, 2012
1 parent 2c2a583 commit b820fba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions horizon/dashboards/nova/images_and_snapshots/images/forms.py
Expand Up @@ -127,6 +127,10 @@ class LaunchForm(forms.SelfHandlingForm):
def __init__(self, *args, **kwargs):
flavor_list = kwargs.pop('flavor_list')
keypair_list = kwargs.pop('keypair_list')
if keypair_list:
keypair_list.insert(0, ("", _("Select a keypair")))
else:
keypair_list = (("", _("No keypairs available.")),)
security_group_list = kwargs.pop('security_group_list')
volume_list = kwargs.pop('volume_list')
super(LaunchForm, self).__init__(*args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions horizon/dashboards/nova/images_and_snapshots/images/tests.py
Expand Up @@ -62,7 +62,7 @@ def test_launch_get(self):
self.assertIn(self.flavors.first().name,
form.fields['flavor'].choices[0][1])
self.assertEqual(self.keypairs.first().name,
form.fields['keypair'].choices[0][0])
form.fields['keypair'].choices[1][0])

def test_launch_post(self):
flavor = self.flavors.first()
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_launch_keypairlist_error(self):
res = self.client.get(url)
self.assertTemplateUsed(res,
'nova/images_and_snapshots/images/launch.html')
self.assertEqual(len(res.context['form'].fields['keypair'].choices), 0)
self.assertEqual(len(res.context['form'].fields['keypair'].choices), 1)

def test_launch_form_keystone_exception(self):
flavor = self.flavors.first()
Expand Down

0 comments on commit b820fba

Please sign in to comment.