mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 08:38:16 -06:00
Use MultipleChoiceField for event_types
This commit is contained in:
parent
41eff5c4c3
commit
1c2b82dedd
@ -1,9 +1,9 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.postgres.forms import SimpleArrayField
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from extras.choices import *
|
from extras.choices import *
|
||||||
from extras.models import *
|
from extras.models import *
|
||||||
|
from netbox.events import get_event_type_choices
|
||||||
from netbox.forms import NetBoxModelBulkEditForm
|
from netbox.forms import NetBoxModelBulkEditForm
|
||||||
from utilities.forms import BulkEditForm, add_blank_choice
|
from utilities.forms import BulkEditForm, add_blank_choice
|
||||||
from utilities.forms.fields import ColorField, CommentField, DynamicModelChoiceField
|
from utilities.forms.fields import ColorField, CommentField, DynamicModelChoiceField
|
||||||
@ -249,10 +249,10 @@ class EventRuleBulkEditForm(NetBoxModelBulkEditForm):
|
|||||||
required=False,
|
required=False,
|
||||||
widget=BulkEditNullBooleanSelect()
|
widget=BulkEditNullBooleanSelect()
|
||||||
)
|
)
|
||||||
event_types = SimpleArrayField(
|
event_types = forms.MultipleChoiceField(
|
||||||
label=_('Event types'),
|
choices=get_event_type_choices(),
|
||||||
base_field=forms.CharField(),
|
required=False,
|
||||||
required=False
|
label=_('Event types')
|
||||||
)
|
)
|
||||||
description = forms.CharField(
|
description = forms.CharField(
|
||||||
label=_('Description'),
|
label=_('Description'),
|
||||||
|
@ -2,7 +2,6 @@ import json
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.postgres.forms import SimpleArrayField
|
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
@ -11,6 +10,7 @@ from core.models import ObjectType
|
|||||||
from dcim.models import DeviceRole, DeviceType, Location, Platform, Region, Site, SiteGroup
|
from dcim.models import DeviceRole, DeviceType, Location, Platform, Region, Site, SiteGroup
|
||||||
from extras.choices import *
|
from extras.choices import *
|
||||||
from extras.models import *
|
from extras.models import *
|
||||||
|
from netbox.events import get_event_type_choices
|
||||||
from netbox.forms import NetBoxModelForm
|
from netbox.forms import NetBoxModelForm
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
from users.models import Group, User
|
from users.models import Group, User
|
||||||
@ -304,9 +304,9 @@ class EventRuleForm(NetBoxModelForm):
|
|||||||
label=_('Object types'),
|
label=_('Object types'),
|
||||||
queryset=ObjectType.objects.with_feature('event_rules'),
|
queryset=ObjectType.objects.with_feature('event_rules'),
|
||||||
)
|
)
|
||||||
event_types = SimpleArrayField(
|
event_types = forms.MultipleChoiceField(
|
||||||
label=_('Event types'),
|
choices=get_event_type_choices(),
|
||||||
base_field=forms.CharField()
|
label=_('Event types')
|
||||||
)
|
)
|
||||||
action_choice = forms.ChoiceField(
|
action_choice = forms.ChoiceField(
|
||||||
label=_('Action choice'),
|
label=_('Action choice'),
|
||||||
@ -324,8 +324,7 @@ class EventRuleForm(NetBoxModelForm):
|
|||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('name', 'description', 'object_types', 'enabled', 'tags', name=_('Event Rule')),
|
FieldSet('name', 'description', 'object_types', 'enabled', 'tags', name=_('Event Rule')),
|
||||||
FieldSet('event_types', name=_('Event Types')),
|
FieldSet('event_types', 'conditions', name=_('Triggers')),
|
||||||
FieldSet('conditions', name=_('Conditions')),
|
|
||||||
FieldSet('action_type', 'action_choice', 'action_data', name=_('Action')),
|
FieldSet('action_type', 'action_choice', 'action_data', name=_('Action')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user