Skip to content

Commit

Permalink
move filtersets to models not meta
Browse files Browse the repository at this point in the history
  • Loading branch information
cruse1977 committed Sep 19, 2024
1 parent 4af0917 commit f950858
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions netbox_acls/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ class AccessListForm(NetBoxModelForm):
)

comments = CommentField()

fieldsets = (
FieldSet('region', 'site_group', 'site', 'virtual_machine', 'virtual_chassis', 'device', name=_('Assignment')),
FieldSet('name', 'type', 'default_action', name=_('Access List')),
FieldSet('comments', 'tags', name=_('')),
)

class Meta:
model = AccessList
fields = (
Expand All @@ -135,11 +140,7 @@ class Meta:
"comments",
"tags",
)
fieldsets = (
FieldSet('region', 'site_group', 'site', 'virtual_machine', 'virtual_chassis', 'device', name=_('Assignment')),
FieldSet('name', 'type', 'default_action', name=_('Access List')),
FieldSet('comments', 'tags', name=_('')),
)

help_texts = {
"default_action": "The default behavior of the ACL.",
"name": "The name uniqueness per device is case insensitive.",
Expand Down Expand Up @@ -291,6 +292,11 @@ class ACLInterfaceAssignmentForm(NetBoxModelForm):
),
)
comments = CommentField()
fieldsets = (
FieldSet('device', 'interface', 'virtual_machine', 'vminterface', name=_('Assignment')),
FieldSet('access_list', 'direction', name=_('Access List Details')),
FieldSet('comments', 'tags', name=_('')),
)

def __init__(self, *args, **kwargs):
# Initialize helper selectors
Expand Down Expand Up @@ -319,11 +325,7 @@ class Meta:
"comments",
"tags",
)
fieldsets = (
FieldSet('device', 'interface', 'virtual_machine', 'vminterface', name=_('Assignment')),
FieldSet('access_list', 'direction', name=_('Access List Details')),
FieldSet('comments', 'tags', name=_('')),
)

help_texts = {
"direction": mark_safe(
"<b>*Note:</b> CANNOT assign 2 ACLs to the same interface & direction.",
Expand Down Expand Up @@ -451,10 +453,9 @@ class ACLStandardRuleForm(NetBoxModelForm):
)

fieldsets = (
("Access List Details", ("access_list", "description", "tags")),
("Rule Definition", ("index", "action", "remark", "source_prefix")),
FieldSet("access_list", "description", "tags", name=_('Access List Details')),
FieldSet("index", "action", "remark", "source_prefix", name=_('Rule Definition'))
)

class Meta:
model = ACLStandardRule
fields = (
Expand All @@ -466,10 +467,7 @@ class Meta:
"tags",
"description",
)
fieldsets = (
FieldSet("access_list", "description", "tags", name=_('Access List Details')),
FieldSet("index", "action", "remark", "source_prefix", name=_('Rule Definition'))
)




Expand Down Expand Up @@ -541,7 +539,10 @@ class ACLExtendedRuleForm(NetBoxModelForm):
help_text=help_text_acl_rule_logic,
label="Destination Prefix",
)

fieldsets = (
FieldSet("access_list", "description", "tags", name=_('Access List Details')),
FieldSet("index", "action", "remark", "source_prefix", "source_ports", "destination_prefix", "destination_ports", "protocol", name=_('Rule Definition'))
)
class Meta:
model = ACLExtendedRule
fields = (
Expand All @@ -557,10 +558,7 @@ class Meta:
"tags",
"description",
)
fieldsets = (
FieldSet("access_list", "description", "tags", name=_('Access List Details')),
FieldSet("index", "action", "remark", "source_prefix", "source_ports", "destination_prefix", "destination_ports", "protocol", name=_('Rule Definition'))
)

help_texts = {
"action": help_text_acl_action,
"destination_ports": help_text_acl_rule_logic,
Expand Down

0 comments on commit f950858

Please sign in to comment.