diff options
author | Zhenguo Niu <Niu.ZGlinux@gmail.com> | 2013-07-25 12:54:01 +0800 |
---|---|---|
committer | Zhenguo Niu <Niu.ZGlinux@gmail.com> | 2013-07-25 13:32:10 +0800 |
commit | 76e06637c1121c8f9fe84e0fb4be769367568e2b (patch) | |
tree | b8e26b2a99515050381c6a57f5e645f4d21503ee | |
parent | 699926413ccfd89207b22fd3c1f5db771665fd37 (diff) | |
download | tuskar-ui-76e06637c1121c8f9fe84e0fb4be769367568e2b.tar.gz |
Add Image Source Field to choose Location or File
Change-Id: I79546c5c2d10b7d6cefdca084f4f7a13ce2939d5
Fixes: bug #1185671
-rw-r--r-- | openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py | 17 | ||||
-rw-r--r-- | openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py | 3 |
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, |