Added "create image" capabiltiy to the admin dashboard.

Change-Id: I6fdffe9fd96df36b07b04e3f9c8d204ab8fd50b1
Fixes: bug #1088736
This commit is contained in:
Cody A.W. Somerville 2013-01-21 17:46:52 -05:00
parent b8071bcce7
commit 10bc52a235
7 changed files with 71 additions and 4 deletions

View File

@ -22,5 +22,9 @@ from openstack_dashboard.dashboards.project.images_and_snapshots \
.images import forms
class AdminCreateImageForm(forms.CreateImageForm):
pass
class AdminUpdateImageForm(forms.UpdateImageForm):
pass

View File

@ -19,7 +19,12 @@ from django.utils.translation import ugettext_lazy as _
from horizon import tables
from openstack_dashboard.dashboards.project.images_and_snapshots \
.images.tables import (ImagesTable, EditImage, DeleteImage)
.images.tables import (ImagesTable, CreateImage, EditImage,
DeleteImage)
class AdminCreateImage(CreateImage):
url = "horizon:admin:images:create"
class AdminDeleteImage(DeleteImage):
@ -42,5 +47,5 @@ class AdminImagesTable(ImagesTable):
class Meta:
name = "images"
verbose_name = _("Images")
table_actions = (AdminDeleteImage,)
table_actions = (AdminCreateImage, AdminDeleteImage)
row_actions = (AdminEditImage, AdminDeleteImage)

View File

@ -0,0 +1,33 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% block form_id %}create_image_form{% endblock %}
{% block form_action %}{% url horizon:admin:images:create %}{% endblock %}
{% block modal-header %}{% trans "Create An Image" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>
{% trans "Specify an image to upload to the Image Service." %}
</p>
<p>
{% trans "Currently only images available via an HTTP URL are supported. The image location must be accessible to the Image Service. Compressed image binaries are supported (.zip and .tar.gz.)" %}
</p>
<p>
<strong>{% trans "Please note: " %}</strong>
{% trans "The Image Location field MUST be a valid and direct URL to the image binary. URLs that redirect or serve error pages will result in unusable images." %}
</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Image" %}" />
<a href="{% url horizon:admin:images:index %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Create An Image" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Create An Image") %}
{% endblock page_header %}
{% block main %}
{% include 'admin/images/_create.html' %}
{% endblock %}

View File

@ -24,6 +24,13 @@ from openstack_dashboard.test import helpers as test
from .tables import AdminImagesTable
class ImageCreateViewTest(test.BaseAdminViewTests):
def test_admin_image_create_view_uses_admin_template(self):
res = self.client.get(
reverse('horizon:admin:images:create'))
self.assertTemplateUsed(res, 'admin/images/create.html')
class ImagesViewTest(test.BaseAdminViewTests):
@test.create_stubs({api: ('image_list_detailed',)})
def test_images_list(self):

View File

@ -20,11 +20,12 @@
from django.conf.urls.defaults import patterns, url
from .views import IndexView, UpdateView, DetailView
from .views import IndexView, CreateView, UpdateView, DetailView
urlpatterns = patterns('openstack_dashboard.dashboards.admin.images.views',
url(r'^images/$', IndexView.as_view(), name='index'),
url(r'^create/$', CreateView.as_view(), name='create'),
url(r'^(?P<image_id>[^/]+)/update/$', UpdateView.as_view(), name='update'),
url(r'^(?P<image_id>[^/]+)/detail/$', DetailView.as_view(), name='detail')
)

View File

@ -30,7 +30,7 @@ from openstack_dashboard import api
from openstack_dashboard.dashboards.project \
.images_and_snapshots.images import views
from .tables import AdminImagesTable
from .forms import AdminUpdateImageForm
from .forms import AdminCreateImageForm, AdminUpdateImageForm
LOG = logging.getLogger(__name__)
@ -57,6 +57,12 @@ class IndexView(tables.DataTableView):
return images
class CreateView(views.CreateView):
template_name = 'admin/images/create.html'
form_class = AdminCreateImageForm
success_url = reverse_lazy('horizon:admin:images:index')
class UpdateView(views.UpdateView):
template_name = 'admin/images/update.html'
form_class = AdminUpdateImageForm