11"""
22Defines each django model's GUI form to add or edit objects for each django model.
33"""
4-
4+ from django . utils . translation import gettext_lazy as _
55from dcim .models import Device , Interface , Region , Site , SiteGroup , VirtualChassis
66from django .contrib .contenttypes .models import ContentType
77from django .core .exceptions import ValidationError
88from django .utils .safestring import mark_safe
99from ipam .models import Prefix
1010from netbox .forms import NetBoxModelForm
11+ from utilities .forms .rendering import FieldSet
1112from utilities .forms .fields import CommentField , DynamicModelChoiceField
1213from virtualization .models import (
1314 Cluster ,
@@ -118,7 +119,12 @@ class AccessListForm(NetBoxModelForm):
118119 )
119120
120121 comments = CommentField ()
121-
122+ fieldsets = (
123+ FieldSet ('region' , 'site_group' , 'site' , 'virtual_machine' , 'virtual_chassis' , 'device' , name = _ ('Assignment' )),
124+ FieldSet ('name' , 'type' , 'default_action' , name = _ ('Access List' )),
125+ FieldSet ('comments' , 'tags' , name = _ ('' )),
126+ )
127+
122128 class Meta :
123129 model = AccessList
124130 fields = (
@@ -134,6 +140,7 @@ class Meta:
134140 "comments" ,
135141 "tags" ,
136142 )
143+
137144 help_texts = {
138145 "default_action" : "The default behavior of the ACL." ,
139146 "name" : "The name uniqueness per device is case insensitive." ,
@@ -285,6 +292,11 @@ class ACLInterfaceAssignmentForm(NetBoxModelForm):
285292 ),
286293 )
287294 comments = CommentField ()
295+ fieldsets = (
296+ FieldSet ('device' , 'interface' , 'virtual_machine' , 'vminterface' , name = _ ('Assignment' )),
297+ FieldSet ('access_list' , 'direction' , name = _ ('Access List Details' )),
298+ FieldSet ('comments' , 'tags' , name = _ ('' )),
299+ )
288300
289301 def __init__ (self , * args , ** kwargs ):
290302 # Initialize helper selectors
@@ -313,6 +325,7 @@ class Meta:
313325 "comments" ,
314326 "tags" ,
315327 )
328+
316329 help_texts = {
317330 "direction" : mark_safe (
318331 "<b>*Note:</b> CANNOT assign 2 ACLs to the same interface & direction." ,
@@ -440,10 +453,9 @@ class ACLStandardRuleForm(NetBoxModelForm):
440453 )
441454
442455 fieldsets = (
443- ( "Access List Details" , ( " access_list" , "description" , "tags" )),
444- ( "Rule Definition" , ( " index" , "action" , "remark" , "source_prefix" )),
456+ FieldSet ( " access_list" , "description" , "tags" , name = _ ( 'Access List Details' )),
457+ FieldSet ( " index" , "action" , "remark" , "source_prefix" , name = _ ( 'Rule Definition' ))
445458 )
446-
447459 class Meta :
448460 model = ACLStandardRule
449461 fields = (
@@ -455,6 +467,10 @@ class Meta:
455467 "tags" ,
456468 "description" ,
457469 )
470+
471+
472+
473+
458474 help_texts = {
459475 "index" : help_text_acl_rule_index ,
460476 "action" : help_text_acl_action ,
@@ -524,22 +540,9 @@ class ACLExtendedRuleForm(NetBoxModelForm):
524540 label = "Destination Prefix" ,
525541 )
526542 fieldsets = (
527- ("Access List Details" , ("access_list" , "description" , "tags" )),
528- (
529- "Rule Definition" ,
530- (
531- "index" ,
532- "action" ,
533- "remark" ,
534- "source_prefix" ,
535- "source_ports" ,
536- "destination_prefix" ,
537- "destination_ports" ,
538- "protocol" ,
539- ),
540- ),
543+ FieldSet ("access_list" , "description" , "tags" , name = _ ('Access List Details' )),
544+ FieldSet ("index" , "action" , "remark" , "source_prefix" , "source_ports" , "destination_prefix" , "destination_ports" , "protocol" , name = _ ('Rule Definition' ))
541545 )
542-
543546 class Meta :
544547 model = ACLExtendedRule
545548 fields = (
@@ -555,6 +558,7 @@ class Meta:
555558 "tags" ,
556559 "description" ,
557560 )
561+
558562 help_texts = {
559563 "action" : help_text_acl_action ,
560564 "destination_ports" : help_text_acl_rule_logic ,
0 commit comments