Remove link for user id field on project action log

The action log under project dashboard should not link
to the user details panel which requires admin permission.

Change-Id: I802188db6f1f8fc7e854980eca85d3b1a75aec1e
Closes-bug: #1667154
This commit is contained in:
Ying Zuo 2017-02-22 15:34:01 -08:00 committed by Akihiro Motoki
parent d4face9967
commit 804db52d7d
4 changed files with 49 additions and 8 deletions

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.core import urlresolvers
from django.template.defaultfilters import title # noqa
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
@ -21,6 +22,7 @@ from horizon import tables
from horizon.utils import filters
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.instances import audit_tables
from openstack_dashboard.dashboards.project.instances \
import tables as project_tables
from openstack_dashboard import policy
@ -187,3 +189,17 @@ class AdminInstancesTable(tables.DataTable):
project_tables.SoftRebootInstance,
project_tables.RebootInstance,
project_tables.DeleteInstance)
def user_link(datum):
return urlresolvers.reverse("horizon:identity:users:detail",
args=(datum.user_id,))
class AdminAuditTable(audit_tables.AuditTable):
user_id = tables.Column('user_id', verbose_name=_('User ID'),
link=user_link)
class Meta(object):
name = 'audit'
verbose_name = _('Instance Action List')

View File

@ -0,0 +1,30 @@
# Copyright 2017 OpenStack Foundation
#
# 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 horizon import tabs
from openstack_dashboard.dashboards.admin.instances import tables
from openstack_dashboard.dashboards.project.instances import tabs \
as project_tabs
class AuditTab(project_tabs.AuditTab):
table_classes = (tables.AdminAuditTable,)
class AdminInstanceDetailTabs(tabs.DetailTabsGroup):
slug = "instance_details"
tabs = (project_tabs.OverviewTab, project_tabs.LogTab,
project_tabs.ConsoleTab, AuditTab)
sticky = True

View File

@ -35,6 +35,7 @@ from openstack_dashboard.dashboards.admin.instances \
import forms as project_forms
from openstack_dashboard.dashboards.admin.instances \
import tables as project_tables
from openstack_dashboard.dashboards.admin.instances import tabs
from openstack_dashboard.dashboards.project.instances import views
from openstack_dashboard.dashboards.project.instances.workflows \
import update_instance
@ -218,6 +219,7 @@ class LiveMigrateView(forms.ModalFormView):
class DetailView(views.DetailView):
tab_group_class = tabs.AdminInstanceDetailTabs
redirect_url = 'horizon:admin:instances:index'
image_url = 'horizon:admin:images:detail'
volume_url = 'horizon:admin:volumes:detail'

View File

@ -13,7 +13,6 @@
# under the License.
from django.core import urlresolvers
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
@ -21,11 +20,6 @@ from horizon import tables
from horizon.utils import filters
def user_link(datum):
return urlresolvers.reverse("horizon:identity:users:detail",
args=(datum.user_id,))
class AuditTable(tables.DataTable):
ACTION_DISPLAY_CHOICES = (
("create", pgettext_lazy("Action log of an instance", u"Create")),
@ -48,8 +42,7 @@ class AuditTable(tables.DataTable):
display_choices=ACTION_DISPLAY_CHOICES)
start_time = tables.Column('start_time', verbose_name=_('Start Time'),
filters=[filters.parse_isotime])
user_id = tables.Column('user_id', verbose_name=_('User ID'),
link=user_link)
user_id = tables.Column('user_id', verbose_name=_('User ID'))
message = tables.Column('message', verbose_name=_('Message'))
class Meta(object):