From e890f906a6039047dfec79299ec580a510d3dbd1 Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Sun, 17 Aug 2025 18:00:03 +0200 Subject: [PATCH 1/2] Linkify ACL rule prefixes --- netbox_acls/tables.py | 51 +++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/netbox_acls/tables.py b/netbox_acls/tables.py index bc26a23e..b2c9d102 100644 --- a/netbox_acls/tables.py +++ b/netbox_acls/tables.py @@ -125,9 +125,9 @@ class Meta(NetBoxTable.Meta): ) -class ACLStandardRuleTable(NetBoxTable): +class ACLRuleTable(NetBoxTable): """ - Defines the table view for the ACLStandardRule model. + Abstract table for all ACL rules. """ access_list = tables.Column( @@ -140,9 +140,11 @@ class ACLStandardRuleTable(NetBoxTable): tags = columns.TagColumn( url_name="plugins:netbox_acls:aclstandardrule_list", ) + source_prefix = tables.Column( + linkify=True, + ) class Meta(NetBoxTable.Meta): - model = ACLStandardRule fields = ( "pk", "id", @@ -159,52 +161,39 @@ class Meta(NetBoxTable.Meta): "index", "action", "remark", - "source_prefix", "tags", + "source_prefix", ) -class ACLExtendedRuleTable(NetBoxTable): +class ACLStandardRuleTable(ACLRuleTable): + """ + Defines the table view for the ACLStandardRule model. + """ + + class Meta(ACLRuleTable.Meta): + model = ACLStandardRule + + +class ACLExtendedRuleTable(ACLRuleTable): """ Defines the table view for the ACLExtendedRule model. """ - access_list = tables.Column( + destination_prefix = tables.Column( linkify=True, ) - index = tables.Column( - linkify=True, - ) - action = ChoiceFieldColumn() - tags = columns.TagColumn( - url_name="plugins:netbox_acls:aclextendedrule_list", - ) protocol = ChoiceFieldColumn() - class Meta(NetBoxTable.Meta): + class Meta(ACLRuleTable.Meta): model = ACLExtendedRule - fields = ( - "pk", - "id", - "access_list", - "index", - "action", - "remark", - "tags", - "description", - "source_prefix", + fields = ACLRuleTable.Meta.fields + ( "source_ports", "destination_prefix", "destination_ports", "protocol", ) - default_columns = ( - "access_list", - "index", - "action", - "remark", - "tags", - "source_prefix", + default_columns = ACLRuleTable.Meta.default_columns + ( "source_ports", "destination_prefix", "destination_ports", From bd9ffe7f36e1cd3e310515d7b16094424fc36e84 Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Sun, 17 Aug 2025 18:23:34 +0200 Subject: [PATCH 2/2] Render ACL rule ports correctly --- netbox_acls/tables.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/netbox_acls/tables.py b/netbox_acls/tables.py index b2c9d102..6fe53c4a 100644 --- a/netbox_acls/tables.py +++ b/netbox_acls/tables.py @@ -180,9 +180,17 @@ class ACLExtendedRuleTable(ACLRuleTable): Defines the table view for the ACLExtendedRule model. """ + source_ports = columns.ArrayColumn( + verbose_name=_("Source Ports"), + empty_values=([],), + ) destination_prefix = tables.Column( linkify=True, ) + destination_ports = columns.ArrayColumn( + verbose_name=_("Destination Ports"), + empty_values=([],), + ) protocol = ChoiceFieldColumn() class Meta(ACLRuleTable.Meta):