mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 13:38:16 -06:00
14132 fix JSON field issue
This commit is contained in:
parent
1d7aace56e
commit
488f0c5427
@ -244,6 +244,14 @@ class EventRuleForm(NetBoxModelForm):
|
||||
label=_('Action choice'),
|
||||
choices=[]
|
||||
)
|
||||
conditions = JSONField(
|
||||
required=False,
|
||||
help_text=_('Enter conditions in <a href="https://json.org/">JSON</a> format.')
|
||||
)
|
||||
action_data = JSONField(
|
||||
required=False,
|
||||
help_text=_('Enter parameters to pass to the action in <a href="https://json.org/">JSON</a> format.')
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
(_('EventRule'), ('name', 'description', 'content_types', 'enabled', 'tags')),
|
||||
@ -268,8 +276,6 @@ class EventRuleForm(NetBoxModelForm):
|
||||
'action_object_type': forms.HiddenInput,
|
||||
'action_object_id': forms.HiddenInput,
|
||||
'action_parameters': forms.HiddenInput,
|
||||
'conditions': forms.Textarea(attrs={'class': 'font-monospace'}),
|
||||
'action_data': forms.Textarea(attrs={'class': 'font-monospace'}),
|
||||
}
|
||||
|
||||
def get_script_choices(self):
|
||||
@ -311,6 +317,8 @@ class EventRuleForm(NetBoxModelForm):
|
||||
elif action_type == EventRuleActionChoices.SCRIPT:
|
||||
self.get_script_choices()
|
||||
|
||||
val = get_field_value(self, 'conditions')
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
|
@ -101,6 +101,8 @@ class JSONField(_JSONField):
|
||||
self.widget.attrs['class'] = 'font-monospace'
|
||||
|
||||
def prepare_value(self, value):
|
||||
if value == '':
|
||||
return value
|
||||
if isinstance(value, InvalidJSONInput):
|
||||
return value
|
||||
if value is None:
|
||||
|
Loading…
Reference in New Issue
Block a user