mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 11:40:58 +00:00
Allow reload of plugin registry when config changes (#5662)
* Allow reload of plugin registry when config changes - Any global settings which control plugin behaviour trigger reload - Plugin registry hash includes the value of these settings - Plugin registry hash is now cached * typo
This commit is contained in:
@ -951,6 +951,16 @@ def update_exchange_rates(setting):
|
||||
InvenTree.tasks.update_exchange_rates()
|
||||
|
||||
|
||||
def reload_plugin_registry(setting):
|
||||
"""When a core plugin setting is changed, reload the plugin registry"""
|
||||
|
||||
from plugin import registry
|
||||
|
||||
logger.info("Reloading plugin registry due to change in setting '%s'", setting.key)
|
||||
|
||||
registry.reload_plugins(full_reload=True, force_reload=True, collect=True)
|
||||
|
||||
|
||||
class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
"""An InvenTreeSetting object is a key:value pair used for storing single values (e.g. one-off settings values).
|
||||
|
||||
@ -1704,7 +1714,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
'description': _('Enable plugins to add URL routes'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
'requires_restart': True,
|
||||
'after_save': reload_plugin_registry,
|
||||
},
|
||||
|
||||
'ENABLE_PLUGINS_NAVIGATION': {
|
||||
@ -1712,7 +1722,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
'description': _('Enable plugins to integrate into navigation'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
'requires_restart': True,
|
||||
'after_save': reload_plugin_registry,
|
||||
},
|
||||
|
||||
'ENABLE_PLUGINS_APP': {
|
||||
@ -1720,7 +1730,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
'description': _('Enable plugins to add apps'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
'requires_restart': True,
|
||||
'after_save': reload_plugin_registry,
|
||||
},
|
||||
|
||||
'ENABLE_PLUGINS_SCHEDULE': {
|
||||
@ -1728,7 +1738,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
'description': _('Enable plugins to run scheduled tasks'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
'requires_restart': True,
|
||||
'after_save': reload_plugin_registry,
|
||||
},
|
||||
|
||||
'ENABLE_PLUGINS_EVENTS': {
|
||||
@ -1736,7 +1746,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
'description': _('Enable plugins to respond to internal events'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
'requires_restart': True,
|
||||
'after_save': reload_plugin_registry,
|
||||
},
|
||||
|
||||
"PROJECT_CODES_ENABLED": {
|
||||
|
Reference in New Issue
Block a user