summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-08-01 20:20:23 +0000
committerGerrit Code Review <review@openstack.org>2013-08-01 20:20:23 +0000
commita81bfc251b33b7f796cc72327159d1e547689523 (patch)
tree16b0d0f5627d8d71cb94dbd214059c3a4a2322f8
parentfe2554a7d69588e440945306249f43619a7dc205 (diff)
parent76e06637c1121c8f9fe84e0fb4be769367568e2b (diff)
downloadtuskar-ui-a81bfc251b33b7f796cc72327159d1e547689523.tar.gz
Merge "Add Image Source Field to choose Location or File"
-rw-r--r--openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py17
-rw-r--r--openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py3
2 files changed, 20 insertions, 0 deletions
diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py
index ac325d43..c8876374 100644
--- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py
+++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py
@@ -44,13 +44,30 @@ class CreateImageForm(forms.SelfHandlingForm):
description = forms.CharField(widget=forms.widgets.Textarea(),
label=_("Description"),
required=False)
+
+ source_type = forms.ChoiceField(
+ label=_('Image Source'),
+ choices=[('url', _('Image Location')),
+ ('file', _('Image File'))],
+ widget=forms.Select(attrs={
+ 'class': 'switchable',
+ 'data-slug': 'source'}))
+
copy_from = forms.CharField(max_length="255",
label=_("Image Location"),
help_text=_("An external (HTTP) URL to load "
"the image from."),
+ widget=forms.TextInput(attrs={
+ 'class': 'switched',
+ 'data-switch-on': 'source',
+ 'data-source-url': _('Image Location')}),
required=False)
image_file = forms.FileField(label=_("Image File"),
help_text=("A local image to upload."),
+ widget=forms.FileInput(attrs={
+ 'class': 'switched',
+ 'data-switch-on': 'source',
+ 'data-source-file': _('Image File')}),
required=False)
disk_format = forms.ChoiceField(label=_('Format'),
required=True,
diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py
index b4d7626f..585804cb 100644
--- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py
+++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py
@@ -50,6 +50,7 @@ class CreateImageFormTests(test.TestCase):
"""
post = {
'name': u'Ubuntu 11.10',
+ 'source_type': u'file',
'description': u'Login with admin/admin',
'disk_format': u'qcow2',
'minimum_disk': 15,
@@ -82,6 +83,7 @@ class ImageViewTests(test.TestCase):
data = {
'name': u'Ubuntu 11.10',
'description': u'Login with admin/admin',
+ 'source_type': u'url',
'copy_from': u'http://cloud-images.ubuntu.com/releases/'
u'oneiric/release/ubuntu-11.10-server-cloudimg'
u'-amd64-disk1.img',
@@ -121,6 +123,7 @@ class ImageViewTests(test.TestCase):
data = {
'name': u'Test Image',
'description': u'Login with admin/admin',
+ 'source_type': u'file',
'image_file': temp_file,
'disk_format': u'qcow2',
'minimum_disk': 15,