Compare commits

..

2 Commits

Author SHA1 Message Date
Ferdinand Thiessen e9fbce0da7 [cli] Added install command to install the database and all plugins
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
2022-07-31 16:33:55 +02:00
Ferdinand Thiessen 47b838804b [plugins][cli] Fix initial migration file + Make sure plugin permissions are installed
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
2022-07-31 16:33:09 +02:00
6 changed files with 11 additions and 12 deletions

View File

@ -1,5 +1,4 @@
import click
from importlib_metadata import entry_points
@click.command()
@ -9,21 +8,14 @@ from importlib_metadata import entry_points
@click.option("--no-core", help="Skip models / types from flaschengeist core", is_flag=True)
def export(namespace, output, no_core, plugin):
from flaschengeist import logger, models
from flaschengeist.app import get_plugins
from .InterfaceGenerator import InterfaceGenerator
gen = InterfaceGenerator(namespace, output, logger)
if not no_core:
gen.run(models)
if plugin:
for entry_point in entry_points(group="flaschengeist.plugins"):
if len(plugin) == 0 or entry_point.name in plugin:
try:
plugin = entry_point.load()
gen.run(plugin.models)
except:
logger.error(
f"Plugin {entry_point.name} could not be loaded due to an error.",
exc_info=True,
)
continue
for plugin_class in get_plugins():
if (len(plugin) == 0 or plugin_class.id in plugin) and plugin_class.models is not None:
gen.run(plugin_class.models)
gen.write()

View File

@ -13,6 +13,7 @@ from flaschengeist.controller import sessionController, userController
class AuthRoutePlugin(Plugin):
id = "dev.flaschengeist.auth"
blueprint = Blueprint("auth", __name__)

View File

@ -14,6 +14,8 @@ from flaschengeist import logger
class AuthPlain(AuthPlugin):
id = "auth_plain"
def install(self):
plugins_installed(self.post_install)

View File

@ -16,6 +16,7 @@ from . import permissions
class RolesPlugin(Plugin):
id = "roles"
blueprint = Blueprint("roles", __name__)
permissions = permissions.permissions

View File

@ -39,6 +39,8 @@ def scheduled(id: str, replace=False, **kwargs):
class SchedulerPlugin(Plugin):
id = "scheduler"
def __init__(self, entry_point, config=None):
super().__init__(entry_point, config)
self.blueprint = Blueprint(self.name, __name__)

View File

@ -18,6 +18,7 @@ from flaschengeist.utils.datetime import from_iso_format
class UsersPlugin(Plugin):
id = "users"
blueprint = Blueprint("users", __name__)
permissions = permissions.permissions