Adding support for multiple plugin types.
This commit is contained in:
@ -8,7 +8,6 @@
|
||||
from flask import current_app
|
||||
from lemur.common.managers import InstanceManager
|
||||
|
||||
|
||||
# inspired by https://github.com/getsentry/sentry
|
||||
class PluginManager(InstanceManager):
|
||||
def __iter__(self):
|
||||
@ -17,8 +16,10 @@ class PluginManager(InstanceManager):
|
||||
def __len__(self):
|
||||
return sum(1 for i in self.all())
|
||||
|
||||
def all(self, version=1):
|
||||
def all(self, version=1, plugin_type=None):
|
||||
for plugin in sorted(super(PluginManager, self).all(), key=lambda x: x.get_title()):
|
||||
if not plugin.type == plugin_type and plugin_type:
|
||||
continue
|
||||
if not plugin.is_enabled():
|
||||
continue
|
||||
if version is not None and plugin.__version__ != version:
|
||||
|
@ -47,12 +47,13 @@ class IPlugin(local):
|
||||
# Configuration specifics
|
||||
conf_key = None
|
||||
conf_title = None
|
||||
options = {}
|
||||
|
||||
# Global enabled state
|
||||
enabled = True
|
||||
can_disable = True
|
||||
|
||||
def is_enabled(self, project=None):
|
||||
def is_enabled(self):
|
||||
"""
|
||||
Returns a boolean representing if this plugin is enabled.
|
||||
If ``project`` is passed, it will limit the scope to that project.
|
||||
|
Reference in New Issue
Block a user