Merge "Allow to edit image metadata from project view"
This commit is contained in:
commit
13fdfce03e
@ -162,6 +162,30 @@ class CreateVolumeFromImage(tables.LinkAction):
|
||||
return False
|
||||
|
||||
|
||||
class UpdateMetadata(tables.LinkAction):
|
||||
name = "update_metadata"
|
||||
verbose_name = _("Update Metadata")
|
||||
ajax = False
|
||||
icon = "pencil"
|
||||
attrs = {"ng-controller": "MetadataModalHelperController as modal"}
|
||||
|
||||
def __init__(self, attrs=None, **kwargs):
|
||||
kwargs['preempt'] = True
|
||||
super(UpdateMetadata, self).__init__(attrs, **kwargs)
|
||||
|
||||
def get_link_url(self, datum):
|
||||
image_id = self.table.get_object_id(datum)
|
||||
self.attrs['ng-click'] = (
|
||||
"modal.openMetadataModal('image', '%s', true)" % image_id)
|
||||
return "javascript:void(0);"
|
||||
|
||||
def allowed(self, request, image=None):
|
||||
return (api.glance.VERSIONS.active >= 2 and
|
||||
image and
|
||||
image.status == "active" and
|
||||
image.owner == request.user.project_id)
|
||||
|
||||
|
||||
def filter_tenants():
|
||||
return getattr(settings, 'IMAGES_LIST_FILTER_TENANTS', [])
|
||||
|
||||
@ -310,5 +334,6 @@ class ImagesTable(tables.DataTable):
|
||||
if getattr(settings, 'LAUNCH_INSTANCE_NG_ENABLED', False):
|
||||
launch_actions = (LaunchImageNG,) + launch_actions
|
||||
row_actions = launch_actions + (CreateVolumeFromImage,
|
||||
EditImage, DeleteImage,)
|
||||
EditImage, UpdateMetadata,
|
||||
DeleteImage,)
|
||||
pagination_param = "image_marker"
|
||||
|
@ -99,11 +99,12 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
||||
row_actions = snaps.get_row_actions(snaps.data[0])
|
||||
|
||||
# first instance - status active, owned
|
||||
self.assertEqual(len(row_actions), 4)
|
||||
self.assertEqual(len(row_actions), 5)
|
||||
self.assertEqual(row_actions[0].verbose_name, u"Launch Instance")
|
||||
self.assertEqual(row_actions[1].verbose_name, u"Create Volume")
|
||||
self.assertEqual(row_actions[2].verbose_name, u"Edit Image")
|
||||
self.assertEqual(row_actions[3].verbose_name, u"Delete Image")
|
||||
self.assertEqual(row_actions[3].verbose_name, u"Update Metadata")
|
||||
self.assertEqual(row_actions[4].verbose_name, u"Delete Image")
|
||||
|
||||
row_actions = snaps.get_row_actions(snaps.data[1])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user