From 78de547871aedb799b9d60c051103c35357fe0bc Mon Sep 17 00:00:00 2001 From: David Lyle Date: Fri, 1 Mar 2019 14:15:21 -0700 Subject: [PATCH] Fix policy function check error Change in I8a346e55bb98e4e22e0c14a614c45d493d20feb4 to make POLICY_CHECK_FUNCTION a string rather than a function was incomplete. The case in horizon/tables/base.py is problematic in particular and results in raising the TypeError: 'str' object is not callable error. There is another instance that is not problematic, but is changed for consistency sake. Change-Id: Ifc616e322eb38ec7e5ac218f7f3c5ccec52e40f4 Closes-Bug: #1818292 --- horizon/tables/base.py | 3 ++- openstack_dashboard/dashboards/admin/dashboard.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/horizon/tables/base.py b/horizon/tables/base.py index c7344a1ed8..4d9aff17f0 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -46,6 +46,7 @@ from horizon.tables.actions import BatchAction from horizon.tables.actions import FilterAction from horizon.tables.actions import LinkAction from horizon.utils import html +from horizon.utils import settings as utils_settings LOG = logging.getLogger(__name__) @@ -380,7 +381,7 @@ class Column(html.HTMLElement): if not self.policy_rules: return True - policy_check = getattr(settings, "POLICY_CHECK_FUNCTION", None) + policy_check = utils_settings.import_setting("POLICY_CHECK_FUNCTION") if policy_check: return policy_check(self.policy_rules, request) diff --git a/openstack_dashboard/dashboards/admin/dashboard.py b/openstack_dashboard/dashboards/admin/dashboard.py index aebef71ce3..43c80ed52b 100644 --- a/openstack_dashboard/dashboards/admin/dashboard.py +++ b/openstack_dashboard/dashboards/admin/dashboard.py @@ -12,18 +12,18 @@ # License for the specific language governing permissions and limitations # under the License. -from django.conf import settings from django.utils.translation import ugettext_lazy as _ from openstack_auth import utils import horizon +from horizon.utils import settings as utils_settings class Admin(horizon.Dashboard): name = _("Admin") slug = "admin" - if getattr(settings, 'POLICY_CHECK_FUNCTION', None): + if utils_settings.import_setting("POLICY_CHECK_FUNCTION"): policy_rules = (('identity', 'admin_required'), ('image', 'context_is_admin'), ('volume', 'context_is_admin'),