Browse Source

Black formatting.

pull/5918/head
Richard Tibbles 2 years ago
parent
commit
d057995b13
  1. 4
      kolibri/plugins/utils/settings.py
  2. 22
      kolibri/plugins/utils/urls.py

4
kolibri/plugins/utils/settings.py

@ -90,9 +90,7 @@ def _apply_base_settings(plugin_instance, settings_module):
app_config = AppConfig.create(plugin_instance.module_path)
app_config.label = plugin_instance.module_path
# Register the plugin as an installed app
_set_setting_value(
"INSTALLED_APPS", (app_config,), settings_module
)
_set_setting_value("INSTALLED_APPS", (app_config,), settings_module)
# Add in the external plugins' locale paths. Our frontend messages depends
# specifically on the value of LOCALE_PATHS to find its catalog files.
if i18n.is_external_plugin(plugin_instance.module_path):

22
kolibri/plugins/utils/urls.py

@ -28,7 +28,11 @@ def find_duplicate_slugs():
if all(map(lambda x: x.startswith("kolibri.plugins"), value)):
# If we have multiple kolibri core plugins setting the same url slug, we should error out.
# This is not acceptable.
raise RuntimeError("Multiple core kolibri plugins define the same top level URL slug: {}".format(key))
raise RuntimeError(
"Multiple core kolibri plugins define the same top level URL slug: {}".format(
key
)
)
duplicate_slugs[key] = value
return duplicate_slugs
@ -45,9 +49,19 @@ def get_urls():
# If we have a collision, and one of the plugins is a kolibri core plugin, we let it take precedence.
# If both are Kolibri core plugins, we have raised a RuntimeError already when checking for
# duplicate slugs.
if slug in duplicate_slugs and not plugin_instance.module_path.startswith("kolibri.plugins"):
other_modules = ", ".join(filter(lambda x: x != plugin_instance.module_path, duplicate_slugs[slug]))
logger.warn("Plugin {} defines a top level URL slug that clashes with other plugins: {}".format(other_modules))
if slug in duplicate_slugs and not plugin_instance.module_path.startswith(
"kolibri.plugins"
):
other_modules = ", ".join(
filter(
lambda x: x != plugin_instance.module_path, duplicate_slugs[slug]
)
)
logger.warn(
"Plugin {} defines a top level URL slug that clashes with other plugins: {}".format(
other_modules
)
)
slug = normalize_slug(plugin_instance.module_path.replace(".", ""))
if url_module:
instance_patterns += i18n_patterns(url_module.urlpatterns, prefix=slug)

Loading…
Cancel
Save