From c76b7b1a739e710e0534c93409b69872de6f6e9b Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Thu, 18 Feb 2016 15:52:49 +0000 Subject: [PATCH] Added patch: Provide_2_simple_methods_to_check_for_disabled_panels.patch Rewritten-From: 779e056008a6299e52f3cedb31f37ec53b4f7081 --- xenial/debian/changelog | 2 +- ...methods_to_check_for_disabled_panels.patch | 108 ++++++++++++++++++ xenial/debian/patches/series | 3 +- 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 xenial/debian/patches/Provide_2_simple_methods_to_check_for_disabled_panels.patch diff --git a/xenial/debian/changelog b/xenial/debian/changelog index 9155799..b17f24d 100644 --- a/xenial/debian/changelog +++ b/xenial/debian/changelog @@ -2,7 +2,7 @@ horizon (2:9.0.0~b2+2016.02.18.git.cda9604792-1) experimental; urgency=medium * New upstream release, based on commit cda9604792. * Fixed (build-)depends for this release. - * Added debian/patches/enable_identity_users_panel.patch. + * Added patch: Provide_2_simple_methods_to_check_for_disabled_panels.patch -- Thomas Goirand Wed, 09 Dec 2015 11:37:40 +0100 diff --git a/xenial/debian/patches/Provide_2_simple_methods_to_check_for_disabled_panels.patch b/xenial/debian/patches/Provide_2_simple_methods_to_check_for_disabled_panels.patch new file mode 100644 index 0000000..e6c806e --- /dev/null +++ b/xenial/debian/patches/Provide_2_simple_methods_to_check_for_disabled_panels.patch @@ -0,0 +1,108 @@ +From 2510cbe01018d22de1f0a7e93dce5ffc82faed73 Mon Sep 17 00:00:00 2001 +From: Itxaka +Date: Wed, 3 Feb 2016 17:37:59 +0100 +Subject: [PATCH] Provide 2 simple methods to check for disabled panels + +Modify settings so we track disabled panels and dashboards +Provide a helper to check if either the dashboard or the +dashboard+panel is enabled/disabled +Provides an example guard on the admin->images tests. + +Change-Id: I65332bdf61e9ed15aaa2138ee08c61cc91347d1d +Closes-Bug: #1541489 +--- + openstack_dashboard/dashboards/admin/images/tests.py | 5 +++++ + openstack_dashboard/test/helpers.py | 12 ++++++++++++ + openstack_dashboard/utils/settings.py | 11 +++++++++++ + 3 files changed, 28 insertions(+) + +diff --git a/openstack_dashboard/dashboards/admin/images/tests.py b/openstack_dashboard/dashboards/admin/images/tests.py +index d4298fb..619dc6c 100644 +--- a/openstack_dashboard/dashboards/admin/images/tests.py ++++ b/openstack_dashboard/dashboards/admin/images/tests.py +@@ -16,6 +16,7 @@ from django.conf import settings + from django.core.urlresolvers import reverse + from django import http + from django.test.utils import override_settings ++import unittest + + from mox3.mox import IsA # noqa + +@@ -25,6 +26,8 @@ from openstack_dashboard.test import helpers as test + from openstack_dashboard.dashboards.admin.images import tables + + ++@unittest.skipIf(test.is_disabled('admin', 'images'), ++ 'Dashboard or panel disabled') + class ImageCreateViewTest(test.BaseAdminViewTests): + @test.create_stubs({api.glance: ('image_list_detailed',)}) + def test_admin_image_create_view_uses_admin_template(self): +@@ -42,6 +45,8 @@ class ImageCreateViewTest(test.BaseAdminViewTests): + self.assertTemplateUsed(res, 'admin/images/create.html') + + ++@unittest.skipIf(test.is_disabled('admin', 'images'), ++ 'Dashboard or panel disabled') + class ImagesViewTest(test.BaseAdminViewTests): + @test.create_stubs({api.glance: ('image_list_detailed',), + api.keystone: ('tenant_list',)}) +diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py +index 5dfa295..7c8a7fb 100644 +--- a/openstack_dashboard/test/helpers.py ++++ b/openstack_dashboard/test/helpers.py +@@ -631,3 +631,15 @@ class update_settings(django_test_utils.override_settings): + copied.update(new_value) + kwargs[key] = copied + super(update_settings, self).__init__(**kwargs) ++ ++ ++def is_disabled(dashboard, panel=None): ++ """Return bool indicating if this dashboard or panel is disabled ++ """ ++ if dashboard in settings.HORIZON_CONFIG['disabled_dashboards']: ++ return True ++ if panel: ++ return bool( ++ panel in settings.HORIZON_CONFIG['disabled_panels'].get(dashboard) ++ ) ++ return False +diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py +index 6a6d16d..894f833 100644 +--- a/openstack_dashboard/utils/settings.py ++++ b/openstack_dashboard/utils/settings.py +@@ -101,6 +101,7 @@ def update_dashboards(modules, horizon_config, installed_apps): + + enabled_dashboards = [] + disabled_dashboards = [] ++ disabled_panels = {} + exceptions = horizon_config.get('exceptions', {}) + apps = [] + angular_modules = [] +@@ -110,7 +111,15 @@ def update_dashboards(modules, horizon_config, installed_apps): + panel_customization = [] + update_horizon_config = {} + for key, config in import_dashboard_config(modules): ++ if config.get('REMOVE_PANEL'): ++ disabled_panels.setdefault( ++ config.get('PANEL_DASHBOARD'), [] ++ ).extend([config.get('PANEL')]) + if config.get('DISABLED', False): ++ if config.get('PANEL'): ++ disabled_panels.setdefault( ++ config.get('PANEL_DASHBOARD'), [] ++ ).extend([config.get('PANEL')]) + if config.get('DASHBOARD'): + disabled_dashboards.append(config.get('DASHBOARD')) + continue +@@ -154,6 +163,8 @@ def update_dashboards(modules, horizon_config, installed_apps): + + horizon_config['panel_customization'] = panel_customization + horizon_config['dashboards'] = tuple(dashboards) ++ horizon_config['disabled_dashboards'] = [d for d in disabled_dashboards] ++ horizon_config['disabled_panels'] = disabled_panels + horizon_config.setdefault('exceptions', {}).update(exceptions) + horizon_config.update(update_horizon_config) + horizon_config.setdefault('angular_modules', []).extend(angular_modules) +-- +1.9.1 + diff --git a/xenial/debian/patches/series b/xenial/debian/patches/series index dbdadcb..b0ff939 100644 --- a/xenial/debian/patches/series +++ b/xenial/debian/patches/series @@ -1,4 +1,5 @@ fix-dashboard-django-wsgi.patch fix-dashboard-manage.patch fixed-horizon-MANIFEST.in.patch -enable_identity_users_panel.patch +#enable_identity_users_panel.patch +Provide_2_simple_methods_to_check_for_disabled_panels.patch -- 2.45.2