From c6efd69daaf84fccfbc36fdb06f1e737912aec86 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 23 2018 11:59:23 +0000 Subject: Add an option to add the default hook/plugin in the list of enabled plugins Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/plugins.py b/pagure/lib/plugins.py index 394f449..b3a4dd3 100644 --- a/pagure/lib/plugins.py +++ b/pagure/lib/plugins.py @@ -50,17 +50,22 @@ def get_plugin(plugin_name): return plugin -def get_enabled_plugins(project): +def get_enabled_plugins(project, with_default=False): """ Returns a list of plugins enabled for a specific project. Args: project (model.Project): The project to look for. + with_default (boolean): Wether or not the returned list should + include the default hook/plugin. Returns: (list): A list of tuples (pluginclass, dbobj) with the plugin classess and dbobjects for plugins enabled for the project. """ from pagure.hooks import BaseHook + from pagure.hooks.default import Default enabled = [] + if with_default: + enabled = [(Default(), None)] for plugin in load("pagure.hooks", subclasses=BaseHook): if plugin.db_object and hasattr(project, plugin.backref): dbobj = getattr(project, plugin.backref)