]> review.fuel-infra Code Review - openstack-build/horizon-build.git/commitdiff
Added patch: Provide_2_simple_methods_to_check_for_disabled_panels.patch
authorThomas Goirand <thomas@goirand.fr>
Thu, 18 Feb 2016 15:52:49 +0000 (15:52 +0000)
committerThomas Goirand <thomas@goirand.fr>
Thu, 18 Feb 2016 15:52:49 +0000 (15:52 +0000)
Rewritten-From: 779e056008a6299e52f3cedb31f37ec53b4f7081

trusty/debian/changelog
trusty/debian/patches/Provide_2_simple_methods_to_check_for_disabled_panels.patch [new file with mode: 0644]
trusty/debian/patches/series

index 91557993647aaf430ba27f41f9988b77130f58a1..b17f24d261469c88bc3a9861b37ddb2ed0a66d38 100644 (file)
@@ -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 <zigo@debian.org>  Wed, 09 Dec 2015 11:37:40 +0100
 
diff --git a/trusty/debian/patches/Provide_2_simple_methods_to_check_for_disabled_panels.patch b/trusty/debian/patches/Provide_2_simple_methods_to_check_for_disabled_panels.patch
new file mode 100644 (file)
index 0000000..e6c806e
--- /dev/null
@@ -0,0 +1,108 @@
+From 2510cbe01018d22de1f0a7e93dce5ffc82faed73 Mon Sep 17 00:00:00 2001
+From: Itxaka <iserrano@redhat.com>
+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
+
index dbdadcbd5eceb9943a9db53c692e104e167b5ebf..b0ff939313a5a448305240d7004a7b8e89080896 100644 (file)
@@ -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