2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +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:
Oliver
2022-01-02 14:12:34 +11:00
parent f3bfe6e7ca
commit dc9e25ebad
23 changed files with 250 additions and 80 deletions

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
""" This module provides template tags for extra functionality
"""
This module provides template tags for extra functionality,
over and above the built-in Django tags.
"""
@ -22,6 +23,8 @@ import InvenTree.helpers
from common.models import InvenTreeSetting, ColorTheme, InvenTreeUserSetting
from common.settings import currency_code_default
from plugin.models import PluginSetting
register = template.Library()
@ -223,8 +226,16 @@ def setting_object(key, *args, **kwargs):
if a user-setting was requested return that
"""
if 'plugin' in kwargs:
# Note, 'plugin' is an instance of an InvenTreePlugin class
plugin = kwargs['plugin']
return PluginSetting.get_setting_object(key, plugin=plugin)
if 'user' in kwargs:
return InvenTreeUserSetting.get_setting_object(key, user=kwargs['user'])
return InvenTreeSetting.get_setting_object(key)