mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Update static files on config change
This commit is contained in:
parent
69057d98f7
commit
163ecab44b
@ -337,7 +337,7 @@ def uninstall_plugin(cfg: plugin.models.PluginConfig, user=None, delete_config=T
|
||||
cfg.delete()
|
||||
|
||||
# Remove static files associated with this plugin
|
||||
plugin.staticfiles.clear_static_dir(f'plugins/{cfg.key}/', recursive=True)
|
||||
plugin.staticfiles.clear_plugin_static_files(cfg.key)
|
||||
|
||||
# Reload the plugin registry
|
||||
registry.reload_plugins(full_reload=True, force_reload=True, collect=True)
|
||||
|
@ -154,6 +154,14 @@ class PluginConfig(InvenTree.models.MetadataMixin, models.Model):
|
||||
warnings.warn('A reload was triggered', stacklevel=2)
|
||||
registry.reload_plugins()
|
||||
|
||||
# Update static files for this plugin
|
||||
if self.active:
|
||||
plugin.staticfiles.copy_plugin_static_files(
|
||||
self.key, check_reload=False
|
||||
)
|
||||
else:
|
||||
plugin.staticfiles.clear_plugin_static_files(self.key)
|
||||
|
||||
@admin.display(boolean=True, description=_('Installed'))
|
||||
def is_installed(self) -> bool:
|
||||
"""Simple check to determine if this plugin is installed.
|
||||
|
@ -115,3 +115,8 @@ def copy_plugin_static_files(slug, check_reload=True):
|
||||
copied += 1
|
||||
|
||||
logger.info("Copied %s static files for plugin '%s'.", copied, slug)
|
||||
|
||||
|
||||
def clear_plugin_static_files(slug: str, recursive: bool = True):
|
||||
"""Clear static files for the specified plugin."""
|
||||
clear_static_dir(f'plugins/{slug}/', recursive=recursive)
|
||||
|
Loading…
Reference in New Issue
Block a user