Files
horizon/openstack_dashboard/dashboards/admin/volume_groups/tables.py
Akihiro Motoki cd7c1b5110 Address RemovedInDjango40Warning (2)
django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
ungettext(), and ungettext_lazy() are deprecated in favor of the
functions that they’re aliases for: django.utils.translation.gettext(),
gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy().

https://docs.djangoproject.com/en/4.0/releases/3.0/#id3

Change-Id: I77878f84e9d10cf6a136dada81eabf4e18676250
2022-02-04 16:22:07 +09:00

74 lines
2.4 KiB
Python

# Copyright 2019 NEC Corporation
#
# 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.
from django.utils.translation import gettext_lazy as _
from horizon import exceptions
from horizon import tables
from openstack_dashboard.api import keystone
from openstack_dashboard.dashboards.project.volume_groups \
import tables as project_tables
class DeleteGroup(project_tables.DeleteGroup):
url = "horizon:admin:volume_groups:delete"
class RemoveAllVolumes(project_tables.RemoveAllVolumes):
url = "horizon:admin:volume_groups:remove_volumes"
class UpdateRow(project_tables.UpdateRow):
ajax = True
def get_data(self, request, group_id):
group = super().get_data(request, group_id)
tenant_id = getattr(group, 'project_id')
try:
tenant = keystone.tenant_get(request, tenant_id)
group.tenant_name = getattr(tenant, "name")
except Exception:
msg = _('Unable to retrieve volume group project information.')
exceptions.handle(request, msg)
return group
class ManageVolumes(project_tables.ManageVolumes):
url = "horizon:admin:volume_groups:manage"
class GroupsTable(project_tables.GroupsTable):
name = tables.WrappingColumn("name_or_id",
verbose_name=_("Name"),
link="horizon:admin:volume_groups:detail")
project = tables.Column("tenant_name", verbose_name=_("Project"))
class Meta(object):
name = "volume_groups"
verbose_name = _("Volume Groups")
table_actions = (
project_tables.GroupsFilterAction,
)
row_actions = (
ManageVolumes,
RemoveAllVolumes,
DeleteGroup,
)
row_class = UpdateRow
status_columns = ("status",)
columns = ('project', 'name', 'description', 'status',
'availability_zone', 'volume_type', 'has_snapshots',)