mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 04:25:42 +00:00
Adds API endpoints for viewing and updating plugin settings
A lot of code updates / refactoring here to get this to work as expected
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Base Class for InvenTree plugins"""
|
||||
|
||||
"""
|
||||
Base Class for InvenTree plugins
|
||||
"""
|
||||
|
||||
from django.db.utils import OperationalError, ProgrammingError
|
||||
from django.utils.text import slugify
|
||||
|
||||
|
||||
@ -10,6 +12,9 @@ class InvenTreePlugin():
|
||||
Base class for a plugin
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
# Override the plugin name for each concrete plugin instance
|
||||
PLUGIN_NAME = ''
|
||||
|
||||
@ -36,5 +41,22 @@ class InvenTreePlugin():
|
||||
|
||||
return self.PLUGIN_TITLE
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
def plugin_config(self, raise_error=False):
|
||||
"""
|
||||
Return the PluginConfig object associated with this plugin
|
||||
"""
|
||||
|
||||
try:
|
||||
import plugin.models
|
||||
|
||||
cfg, _ = plugin.models.PluginConfig.objects.get_or_create(
|
||||
key=self.plugin_slug(),
|
||||
name=self.plugin_name(),
|
||||
)
|
||||
except (OperationalError, ProgrammingError) as error:
|
||||
cfg = None
|
||||
|
||||
if raise_error:
|
||||
raise error
|
||||
|
||||
return cfg
|
||||
|
Reference in New Issue
Block a user