mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-11 09:48:50 +00:00
Allow settings value to be nullified (#8596)
* Allow settings value to be nullified * Additional null check * Bump API version * Fix for unit test
This commit is contained in:
parent
327884ca26
commit
3149ae79ce
@ -1,13 +1,16 @@
|
|||||||
"""InvenTree API version information."""
|
"""InvenTree API version information."""
|
||||||
|
|
||||||
# InvenTree API version
|
# InvenTree API version
|
||||||
INVENTREE_API_VERSION = 290
|
INVENTREE_API_VERSION = 291
|
||||||
|
|
||||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||||
|
|
||||||
|
|
||||||
INVENTREE_API_TEXT = """
|
INVENTREE_API_TEXT = """
|
||||||
|
|
||||||
|
v291 - 2024-11-30 : https://github.com/inventree/InvenTree/pull/8596
|
||||||
|
- Allow null / empty values for plugin settings
|
||||||
|
|
||||||
v290 - 2024-11-29 : https://github.com/inventree/InvenTree/pull/8590
|
v290 - 2024-11-29 : https://github.com/inventree/InvenTree/pull/8590
|
||||||
- Adds "quantity" field to ReturnOrderLineItem model and API
|
- Adds "quantity" field to ReturnOrderLineItem model and API
|
||||||
|
|
||||||
|
@ -41,11 +41,19 @@ class SettingsValueField(serializers.Field):
|
|||||||
|
|
||||||
Protected settings are returned as '***'
|
Protected settings are returned as '***'
|
||||||
"""
|
"""
|
||||||
return '***' if instance.protected else str(instance.value)
|
if instance.protected:
|
||||||
|
return '***'
|
||||||
|
elif instance.value is None:
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
|
return str(instance.value)
|
||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
"""Return the internal value of the setting."""
|
"""Return the internal value of the setting."""
|
||||||
return str(data)
|
if data is None:
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
|
return str(data)
|
||||||
|
|
||||||
|
|
||||||
class SettingsSerializer(InvenTreeModelSerializer):
|
class SettingsSerializer(InvenTreeModelSerializer):
|
||||||
@ -65,7 +73,13 @@ class SettingsSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
api_url = serializers.CharField(read_only=True)
|
api_url = serializers.CharField(read_only=True)
|
||||||
|
|
||||||
value = SettingsValueField()
|
value = SettingsValueField(allow_null=True)
|
||||||
|
|
||||||
|
def validate_value(self, value):
|
||||||
|
"""Validate the value of the setting."""
|
||||||
|
if value is None:
|
||||||
|
return ''
|
||||||
|
return str(value)
|
||||||
|
|
||||||
units = serializers.CharField(read_only=True)
|
units = serializers.CharField(read_only=True)
|
||||||
|
|
||||||
@ -185,6 +199,12 @@ class GenericReferencedSettingSerializer(SettingsSerializer):
|
|||||||
# resume operations
|
# resume operations
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def validate_value(self, value):
|
||||||
|
"""Validate the value of the setting."""
|
||||||
|
if value is None:
|
||||||
|
return ''
|
||||||
|
return str(value)
|
||||||
|
|
||||||
|
|
||||||
class NotificationMessageSerializer(InvenTreeModelSerializer):
|
class NotificationMessageSerializer(InvenTreeModelSerializer):
|
||||||
"""Serializer for the InvenTreeUserSetting model."""
|
"""Serializer for the InvenTreeUserSetting model."""
|
||||||
|
@ -68,6 +68,7 @@ export function SettingList({
|
|||||||
fields: {
|
fields: {
|
||||||
value: {
|
value: {
|
||||||
field_type: fieldType,
|
field_type: fieldType,
|
||||||
|
required: setting?.required ?? false,
|
||||||
label: setting?.name,
|
label: setting?.name,
|
||||||
description: setting?.description,
|
description: setting?.description,
|
||||||
api_url: setting?.api_url ?? '',
|
api_url: setting?.api_url ?? '',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user