mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-06 10:21:18 +00:00
Add some helper magic for setting objects
- If the setting is defined as a "bool" then the returned value is automatically cast to a bool - Add some more unit testing
This commit is contained in:
1 parent
75ab7b247b
commit
c95f124578
5 files changed
+112
-7
No files matched your search
@@ -85,6 +85,13 @@ class InvenTreeSetting(models.Model):
|
||||
'validator': bool
|
||||
},
|
||||
|
||||
'PART_COMPONENT': {
|
||||
'name': _('Component'),
|
||||
'description': _('Parts can be used as sub-components by default'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
|
||||
'PART_PURCHASEABLE': {
|
||||
'name': _('Purchaseable'),
|
||||
'description': _('Parts are purchaseable by default'),
|
||||
@@ -264,6 +271,11 @@ class InvenTreeSetting(models.Model):
|
||||
|
||||
if setting:
|
||||
value = setting.value
|
||||
|
||||
# If the particular setting is defined as a boolean, cast the value to a boolean
|
||||
if setting.is_bool():
|
||||
value = InvenTree.helpers.str2bool(value)
|
||||
|
||||
else:
|
||||
value = backup_value
|
||||
|
||||
|
||||
Reference in new issue
Block a user