mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
refactor
This commit is contained in:
parent
fd5939d233
commit
f13507e23c
@ -179,12 +179,7 @@ class PluginAppConfig(AppConfig):
|
|||||||
# add them to the INSTALLED_APPS
|
# add them to the INSTALLED_APPS
|
||||||
for slug, plugin in plugins:
|
for slug, plugin in plugins:
|
||||||
if plugin.mixin_enabled('app'):
|
if plugin.mixin_enabled('app'):
|
||||||
try:
|
plugin_path = self._get_plugin_path(plugin)
|
||||||
# for local path plugins
|
|
||||||
plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(settings.BASE_DIR).parts)
|
|
||||||
except ValueError:
|
|
||||||
# plugin is shipped as package
|
|
||||||
plugin_path = plugin.PLUGIN_NAME
|
|
||||||
if plugin_path not in settings.INSTALLED_APPS:
|
if plugin_path not in settings.INSTALLED_APPS:
|
||||||
settings.INSTALLED_APPS += [plugin_path]
|
settings.INSTALLED_APPS += [plugin_path]
|
||||||
settings.INTEGRATION_APPS_PATHS += [plugin_path]
|
settings.INTEGRATION_APPS_PATHS += [plugin_path]
|
||||||
@ -196,6 +191,15 @@ class PluginAppConfig(AppConfig):
|
|||||||
# update urls
|
# update urls
|
||||||
self._update_urls()
|
self._update_urls()
|
||||||
|
|
||||||
|
def _get_plugin_path(self, plugin):
|
||||||
|
try:
|
||||||
|
# for local path plugins
|
||||||
|
plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(settings.BASE_DIR).parts)
|
||||||
|
except ValueError:
|
||||||
|
# plugin is shipped as package
|
||||||
|
plugin_path = plugin.PLUGIN_NAME
|
||||||
|
return plugin_path
|
||||||
|
|
||||||
def deactivate_integration_app(self):
|
def deactivate_integration_app(self):
|
||||||
# remove plugin from installed_apps
|
# remove plugin from installed_apps
|
||||||
for plugin in settings.INTEGRATION_APPS_PATHS:
|
for plugin in settings.INTEGRATION_APPS_PATHS:
|
||||||
|
Loading…
Reference in New Issue
Block a user