2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 21:15:41 +00:00

Plugin missing fix (#5653)

* Add 'is_installed' property to PluginConfig model

- Allow us to show users which plugins are "outdated"

* Cleanup plugin table

- Display clearly if a plugin is no longer installed

* Fixes for plugin table

* Revert change due to failing CI
This commit is contained in:
Oliver
2023-10-03 19:44:10 +11:00
committed by GitHub
parent 88314da7b3
commit 78905a45c7
5 changed files with 50 additions and 24 deletions

View File

@ -104,9 +104,9 @@ class PluginConfig(InvenTree.models.MetadataMixin, models.Model):
self.plugin: InvenTreePlugin = plugin
def __getstate__(self):
"""Customize pickeling behaviour."""
"""Customize pickling behavior."""
state = super().__getstate__()
state.pop("plugin", None) # plugin cannot be pickelt in some circumstances when used with drf views, remove it (#5408)
state.pop("plugin", None) # plugin cannot be pickled in some circumstances when used with drf views, remove it (#5408)
return state
def save(self, force_insert=False, force_update=False, *args, **kwargs):
@ -120,14 +120,23 @@ class PluginConfig(InvenTree.models.MetadataMixin, models.Model):
self.active = True
if not reload:
if (self.active is False and self.__org_active is True) or \
(self.active is True and self.__org_active is False):
if self.active != self.__org_active:
if settings.PLUGIN_TESTING:
warnings.warn('A reload was triggered', stacklevel=2)
registry.reload_plugins()
return ret
@admin.display(boolean=True, description=_('Installed'))
def is_installed(self) -> bool:
"""Simple check to determine if this plugin is installed.
A plugin might not be installed if it has been removed from the system,
but the PluginConfig associated with it still exists.
"""
return self.plugin is not None
@admin.display(boolean=True, description=_('Sample plugin'))
def is_sample(self) -> bool:
"""Is this plugin a sample app?"""