Skip to content

Commit 9cdbf58

Browse files
committed
update BaseACLRuleForm
1 parent 930a40c commit 9cdbf58

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

netbox_acls/forms/models.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -543,16 +543,17 @@ class BaseACLRuleForm(NetBoxModelForm):
543543
class Meta:
544544
"""Defines the Model and fields to be used by the form."""
545545

546-
model = ACLStandardRule
546+
abstract = True
547+
model = BaseACLRule
547548
fields = (
548549
"access_list",
549550
"index",
550551
"action",
551552
"remark",
552-
"source_prefix",
553553
"tags",
554554
"description",
555555
)
556+
# Adds a help text to the form fields where the field is not defined in the form class.
556557
help_texts = {
557558
"action": HELP_TEXT_ACL_ACTION,
558559
"destination_ports": HELP_TEXT_ACL_RULE_LOGIC,
@@ -617,6 +618,13 @@ class ACLStandardRuleForm(BaseACLRuleForm):
617618
See the clean function for logic on other field requirements.
618619
"""
619620

621+
class Meta(BaseACLRuleForm.Meta):
622+
"""Defines the Model and fields to be used by the form."""
623+
624+
model = ACLStandardRule
625+
# Need to add source_prefix to the tuple here instead of base or it will cause a ValueError
626+
fields = BaseACLRuleForm.Meta.fields + ("source_prefix",)
627+
620628

621629
class ACLExtendedRuleForm(BaseACLRuleForm):
622630
"""
@@ -648,20 +656,14 @@ class ACLExtendedRuleForm(BaseACLRuleForm):
648656
),
649657
)
650658

651-
class Meta:
659+
class Meta(BaseACLRuleForm.Meta):
652660
"""Defines the Model and fields to be used by the form."""
653661

654662
model = ACLExtendedRule
655-
fields = (
656-
"access_list",
657-
"index",
658-
"action",
659-
"remark",
663+
fields = BaseACLRuleForm.Meta.fields + (
660664
"source_prefix",
661665
"source_ports",
662666
"destination_prefix",
663667
"destination_ports",
664668
"protocol",
665-
"tags",
666-
"description",
667669
)

0 commit comments

Comments
 (0)