Add is_available hook for plugin configs

This commit is contained in:
Raphael Michel
2019-01-12 14:10:56 +01:00
parent 75a966529e
commit d5ac155914
5 changed files with 13 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ class PluginType(Enum):
EXPORT = 4
def get_all_plugins() -> List[type]:
def get_all_plugins(event=None) -> List[type]:
"""
Returns the PretixPluginMeta classes of all plugins found in the installed Django apps.
"""
@@ -29,6 +29,11 @@ def get_all_plugins() -> List[type]:
meta.app = app
if app.name in settings.PRETIX_PLUGINS_EXCLUDE:
continue
if hasattr(app, 'is_available') and event:
if not app.is_available(event):
continue
plugins.append(meta)
return sorted(
plugins,