mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 08:25:17 -06:00
10348 add decimal custom field
This commit is contained in:
parent
0190c0225e
commit
d9a4d46046
@ -99,6 +99,8 @@ class CustomFieldSerializer(ValidatedModelSerializer):
|
||||
types = CustomFieldTypeChoices
|
||||
if obj.type == types.TYPE_INTEGER:
|
||||
return 'integer'
|
||||
if obj.type == types.TYPE_DECIMAL:
|
||||
return 'decimal'
|
||||
if obj.type == types.TYPE_BOOLEAN:
|
||||
return 'boolean'
|
||||
if obj.type in (types.TYPE_JSON, types.TYPE_OBJECT):
|
||||
|
@ -10,6 +10,7 @@ class CustomFieldTypeChoices(ChoiceSet):
|
||||
TYPE_TEXT = 'text'
|
||||
TYPE_LONGTEXT = 'longtext'
|
||||
TYPE_INTEGER = 'integer'
|
||||
TYPE_DECIMAL = 'decimal'
|
||||
TYPE_BOOLEAN = 'boolean'
|
||||
TYPE_DATE = 'date'
|
||||
TYPE_URL = 'url'
|
||||
@ -23,6 +24,7 @@ class CustomFieldTypeChoices(ChoiceSet):
|
||||
(TYPE_TEXT, 'Text'),
|
||||
(TYPE_LONGTEXT, 'Text (long)'),
|
||||
(TYPE_INTEGER, 'Integer'),
|
||||
(TYPE_DECIMAL, 'Decimal'),
|
||||
(TYPE_BOOLEAN, 'Boolean (true/false)'),
|
||||
(TYPE_DATE, 'Date'),
|
||||
(TYPE_URL, 'URL'),
|
||||
|
@ -317,6 +317,15 @@ class CustomField(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLogge
|
||||
max_value=self.validation_maximum
|
||||
)
|
||||
|
||||
# Decimal
|
||||
if self.type == CustomFieldTypeChoices.TYPE_DECIMAL:
|
||||
field = forms.DecimalField(
|
||||
required=required,
|
||||
initial=initial,
|
||||
max_digits=10,
|
||||
decimal_places=2,
|
||||
)
|
||||
|
||||
# Boolean
|
||||
elif self.type == CustomFieldTypeChoices.TYPE_BOOLEAN:
|
||||
choices = (
|
||||
|
Loading…
Reference in New Issue
Block a user