Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converts images and snapshots to new tables, modals, error handling, …
…etc. Fixed bug 905235. Fixed bug 906487. Change-Id: Ida68d82508357fe31695c0c66f7aaeabdc911105
- Loading branch information
1 parent
1e9a178
commit 9f9d4ab
Showing
25 changed files
with
400 additions
and
666 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
horizon/horizon/dashboards/nova/images_and_snapshots/images/tables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 | ||
|
||
# Copyright 2012 Nebula, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import logging | ||
|
||
from django import shortcuts | ||
from django.contrib import messages | ||
from django.core.urlresolvers import reverse | ||
from django.template import defaultfilters as filters | ||
from novaclient import exceptions as novaclient_exceptions | ||
|
||
from horizon import api | ||
from horizon import tables | ||
|
||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class DeleteImage(tables.DeleteAction): | ||
data_type_singular = _("Image") | ||
data_type_plural = _("Images") | ||
|
||
def allowed(self, request, image=None): | ||
if image: | ||
return image.owner == request.user.id | ||
return True | ||
|
||
def delete(self, request, obj_id): | ||
api.image_delete(request, obj_id) | ||
|
||
|
||
class LaunchImage(tables.LinkAction): | ||
name = "launch" | ||
verbose_name = _("Launch") | ||
url = "horizon:nova:images_and_snapshots:images:launch" | ||
attrs = {"class": "ajax-modal"} | ||
|
||
|
||
class EditImage(tables.LinkAction): | ||
name = "edit" | ||
verbose_name = _("Edit") | ||
url = "horizon:nova:images_and_snapshots:images:update" | ||
attrs = {"class": "ajax-modal"} | ||
|
||
|
||
def get_image_type(image): | ||
return getattr(image.properties, "image_type", "Image") | ||
|
||
|
||
class ImagesTable(tables.DataTable): | ||
name = tables.Column("name") | ||
image_type = tables.Column(get_image_type, | ||
verbose_name=_("Type"), | ||
filters=(filters.title,)) | ||
status = tables.Column("status", filters=(filters.title,)) | ||
public = tables.Column("is_public", | ||
verbose_name=_("Public"), | ||
empty_value=False, | ||
filters=(filters.yesno, filters.capfirst)) | ||
container_format = tables.Column("container_format", | ||
verbose_name=_("Container Format"), | ||
filters=(unicode.upper,)) | ||
|
||
class Meta: | ||
name = "images" | ||
verbose_name = _("Images") | ||
table_actions = (DeleteImage,) | ||
row_actions = (LaunchImage, EditImage, DeleteImage) |
Oops, something went wrong.