mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Force builtin plugins to be active (#4276)
* Force builtin plugins to be active - Not setting the "active" flag can cause ambiguous errors - e.g. some settings don't work if the plugin is inactive - By design, builtin plugins are always "active" anyway - This PR just forces the active field to True * Fix unit tests
This commit is contained in:
parent
50eb81f495
commit
06eb3a81b6
@ -148,6 +148,10 @@ class PluginConfig(models.Model):
|
|||||||
|
|
||||||
ret = super().save(force_insert, force_update, *args, **kwargs)
|
ret = super().save(force_insert, force_update, *args, **kwargs)
|
||||||
|
|
||||||
|
if self.is_builtin():
|
||||||
|
# Force active if builtin
|
||||||
|
self.active = True
|
||||||
|
|
||||||
if not reload:
|
if not reload:
|
||||||
if (self.active is False and self.__org_active is True) or \
|
if (self.active is False and self.__org_active is True) or \
|
||||||
(self.active is True and self.__org_active is False):
|
(self.active is True and self.__org_active is False):
|
||||||
|
@ -408,6 +408,11 @@ class PluginsRegistry:
|
|||||||
# Check if this is a 'builtin' plugin
|
# Check if this is a 'builtin' plugin
|
||||||
builtin = plg.check_is_builtin()
|
builtin = plg.check_is_builtin()
|
||||||
|
|
||||||
|
# Auto-enable builtin plugins
|
||||||
|
if builtin and plg_db and not plg_db.active:
|
||||||
|
plg_db.active = True
|
||||||
|
plg_db.save()
|
||||||
|
|
||||||
# Determine if this plugin should be loaded:
|
# Determine if this plugin should be loaded:
|
||||||
# - If PLUGIN_TESTING is enabled
|
# - If PLUGIN_TESTING is enabled
|
||||||
# - If this is a 'builtin' plugin
|
# - If this is a 'builtin' plugin
|
||||||
|
@ -193,8 +193,3 @@ class PluginDetailAPITest(PluginMixin, InvenTreeAPITestCase):
|
|||||||
with self.assertRaises(NotFound) as exc:
|
with self.assertRaises(NotFound) as exc:
|
||||||
check_plugin(plugin_slug=None, plugin_pk='123')
|
check_plugin(plugin_slug=None, plugin_pk='123')
|
||||||
self.assertEqual(str(exc.exception.detail), "Plugin '123' not installed")
|
self.assertEqual(str(exc.exception.detail), "Plugin '123' not installed")
|
||||||
|
|
||||||
# Not active
|
|
||||||
with self.assertRaises(NotFound) as exc:
|
|
||||||
check_plugin(plugin_slug='inventreebarcode', plugin_pk=None)
|
|
||||||
self.assertEqual(str(exc.exception.detail), "Plugin 'inventreebarcode' is not active")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user