From b5b77303d1b5231ca6bfff57e4019c7ee5371bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Duch=C3=AAne?= Date: Mon, 17 Jun 2024 15:22:51 +0200 Subject: [PATCH] Add script to setup imio.webspellchecker --- dev.cfg | 1 + scripts/install_wsc.py | 30 ++++++++++++++++++++++++++++++ scripts/update_all_local_roles.py | 6 +++++- sources.cfg | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 scripts/install_wsc.py diff --git a/dev.cfg b/dev.cfg index 89440cc..8799f29 100644 --- a/dev.cfg +++ b/dev.cfg @@ -53,6 +53,7 @@ auto-checkout = ftw.labels imio.pm.locales imio.pm.ws +# imio.webspellchecker imio.zamqp.core imio.zamqp.pm plone.restapi diff --git a/scripts/install_wsc.py b/scripts/install_wsc.py new file mode 100644 index 0000000..bdae1a6 --- /dev/null +++ b/scripts/install_wsc.py @@ -0,0 +1,30 @@ +from imio.helpers.security import setup_app +from imio.helpers.security import setup_logger +from imio.webspellchecker import config as webspellchecker_config +from os import getenv +from plone import api +from Products.PloneMeeting import logger + +import logging +import sys +import transaction + + +setup_logger(level=logging.INFO) +setup_app(app) +with api.env.adopt_user(username="admin"): + logger.info("Installing webspellchecker...") + WSC_JS_BUNDLE_URL = getenv("WSC_JS_BUNDLE_URL") + WSC_SERVICE_URL = getenv("WSC_SERVICE_URL") + if not WSC_JS_BUNDLE_URL or not WSC_SERVICE_URL: + logger.error("Missing webspellchecker environment variables. Aborting installation.") + sys.exit(-1) + + portal = api.portal.get() + portal.portal_setup.runImportStepFromProfile( + 'profile-Products.PloneMeeting:default', + 'PloneMeeting-Install-Imio-Webspellchecker') + webspellchecker_config.set_js_bundle_url(WSC_JS_BUNDLE_URL.decode('utf-8')) + webspellchecker_config.set_service_url(WSC_SERVICE_URL.decode('utf-8')) + transaction.commit() + logger.info("Installed webspellchecker.") diff --git a/scripts/update_all_local_roles.py b/scripts/update_all_local_roles.py index e149f50..98464be 100644 --- a/scripts/update_all_local_roles.py +++ b/scripts/update_all_local_roles.py @@ -1,10 +1,14 @@ -from plone import api from imio.helpers.security import setup_app from imio.helpers.security import setup_logger +from plone import api + import logging +import transaction + setup_logger(level=logging.INFO) setup_app(app) with api.env.adopt_user(username="admin"): tool = api.portal.get_tool("portal_plonemeeting") tool.update_all_local_roles(redirect=False) + transaction.commit() diff --git a/sources.cfg b/sources.cfg index cebd1b6..ed4108e 100644 --- a/sources.cfg +++ b/sources.cfg @@ -51,6 +51,7 @@ imio.pm.locales = git ${remotes:imio}/imio.pm.locales.git pushurl=${remotes:imio imio.pm.ws = git ${remotes:imio}/imio.pm.ws.git pushurl=${remotes:imio_push}/imio.pm.ws.git imio.prettylink = git ${remotes:imio}/imio.prettylink.git pushurl=${remotes:imio_push}/imio.prettylink.git imio.pyutils = git ${remotes:imio}/imio.pyutils.git pushurl=${remotes:imio_push}/imio.pyutils.git +imio.webspellchecker = git ${remotes:imio}/imio.webspellchecker.git pushurl=${remotes:imio_push}/imio.webspellchecker.git imio.zamqp.core = git ${remotes:imio}/imio.zamqp.core.git pushurl=${remotes:imio_push}/imio.zamqp.core.git imio.zamqp.pm = git ${remotes:imio}/imio.zamqp.pm.git pushurl=${remotes:imio_push}/imio.zamqp.pm.git