mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 05:25:42 +00:00
Enable and disable plugins via the API (#4964)
* Cleanup plugin settings page - Template adjustments * Activate plugin directly via API * Update plugin activate endpoint - Allow plugin to be deactivated also - Default value = True if not provided * Update front-end / js - Allow same JS method to either enable or disable a plugin * Hide info for plugins which are not active * remove duplicated column * Tweak serializer docstring * Fix typo * Add extra data to plugin serializer - is_builtin - is_sample * Some backend cleanup - Don't stringify null values - Don't replace None with "Unavailable" * front-end table for rendering plugins * Change default sorting - Show active plugins first * Fix button callback * Remove old template * JS linting * More linting
This commit is contained in:
@ -76,11 +76,22 @@ class PluginConfig(models.Model):
|
||||
plugin = registry.plugins_full.get(self.key, None)
|
||||
|
||||
def get_plugin_meta(name):
|
||||
"""Return a meta-value associated with this plugin"""
|
||||
|
||||
# Ignore if the plugin config is not defined
|
||||
if not plugin:
|
||||
return None
|
||||
|
||||
# Ignore if the plugin is not active
|
||||
if not self.active:
|
||||
return _('Unvailable')
|
||||
return str(getattr(plugin, name, None))
|
||||
return None
|
||||
|
||||
result = getattr(plugin, name, None)
|
||||
|
||||
if result is not None:
|
||||
result = str(result)
|
||||
|
||||
return result
|
||||
|
||||
self.meta = {
|
||||
key: get_plugin_meta(key) for key in ['slug', 'human_name', 'description', 'author',
|
||||
|
Reference in New Issue
Block a user