mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Render "native value" in serializer
This commit is contained in:
parent
5d4972d981
commit
75fa0bed26
@ -398,6 +398,17 @@ class BaseInvenTreeSetting(models.Model):
|
|||||||
def units(self):
|
def units(self):
|
||||||
return self.__class__.get_setting_units(self.key)
|
return self.__class__.get_setting_units(self.key)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def native_value(self):
|
||||||
|
|
||||||
|
if self.is_bool():
|
||||||
|
return self.as_bool()
|
||||||
|
|
||||||
|
if self.is_int():
|
||||||
|
return self.as_int()
|
||||||
|
|
||||||
|
return self.value
|
||||||
|
|
||||||
def clean(self, **kwargs):
|
def clean(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
If a validator (or multiple validators) are defined for a particular setting key,
|
If a validator (or multiple validators) are defined for a particular setting key,
|
||||||
@ -636,6 +647,9 @@ class BaseInvenTreeSetting(models.Model):
|
|||||||
|
|
||||||
return setting.get('protected', False)
|
return setting.get('protected', False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def protected(self):
|
||||||
|
return self.__class__.is_protected(self.key)
|
||||||
|
|
||||||
def settings_group_options():
|
def settings_group_options():
|
||||||
"""
|
"""
|
||||||
|
@ -50,11 +50,12 @@ class SettingsSerializer(InvenTreeModelSerializer):
|
|||||||
"""
|
"""
|
||||||
Make sure protected values are not returned
|
Make sure protected values are not returned
|
||||||
"""
|
"""
|
||||||
result = obj.value
|
|
||||||
|
|
||||||
# never return protected values
|
# never return protected values
|
||||||
if obj.is_protected:
|
if obj.protected:
|
||||||
result = '***'
|
result = '***'
|
||||||
|
else:
|
||||||
|
result = obj.value
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user