From a90fdecdf1867d52c8a633c060ec29c7c0131147 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 02 2015 11:40:55 +0000 Subject: [PATCH 1/3] Adjust get_plugin_names to support a list of blacklisted plugins This way we can avoid showing in the UI plugins that are not activated. --- diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py index df090e9..d2c9aeb 100644 --- a/pagure/ui/plugins.py +++ b/pagure/ui/plugins.py @@ -23,10 +23,18 @@ from pagure.lib.model import BASE # pylint: disable=E1101 -def get_plugin_names(): +def get_plugin_names(blacklist=None): ''' Return the list of plugins names. ''' plugins = load('pagure.hooks', subclasses=BaseHook) - output = [plugin.name for plugin in plugins] + if not blacklist: + blacklist = [] + elif not isinstance(blacklist, list): + blacklist = [blacklist] + output = [ + plugin.name + for plugin in plugins + if plugin.name not in blacklist + ] return output From 2f11a5bf9b822f33b5c9bd0d6a7f80e577bf39ae Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 02 2015 11:41:23 +0000 Subject: [PATCH 2/3] If the user tries to access the plugin's page directly, block the request --- diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py index d2c9aeb..7ff7500 100644 --- a/pagure/ui/plugins.py +++ b/pagure/ui/plugins.py @@ -78,6 +78,9 @@ def view_plugin(repo, plugin, username=None, full=True): 403, 'You are not allowed to change the settings for this project') + if plugin in APP.config.get('DISABLED_PLUGINS', []): + flask.abort(404, 'Plugin disabled') + plugin = get_plugin(plugin) fields = [] new = True From 53bee71e2ae42ac03a92d53da81b0eb026bb8b83 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 02 2015 11:41:40 +0000 Subject: [PATCH 3/3] Pass on to get_plugin_names the potential list of blacklisted project --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 4933eda..00639d0 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -642,7 +642,8 @@ def view_settings(repo, username=None): 403, 'You are not allowed to change the settings for this project') - plugins = pagure.ui.plugins.get_plugin_names() + plugins = pagure.ui.plugins.get_plugin_names( + APP.config.get('DISABLED_PLUGINS')) tags = pagure.lib.get_tags_of_project(SESSION, repo) form = pagure.forms.ConfirmationForm()