diff --git a/netbox_acls/tables.py b/netbox_acls/tables.py index 7e595839..e6690fcf 100644 --- a/netbox_acls/tables.py +++ b/netbox_acls/tables.py @@ -6,7 +6,7 @@ from django.utils.translation import gettext_lazy as _ from netbox.tables import NetBoxTable, columns -from .models import AccessList, ACLExtendedRule, ACLAssignment, ACLStandardRule +from .models import AccessList, ACLAssignment, ACLExtendedRule, ACLStandardRule __all__ = ( "AccessListTable", @@ -58,7 +58,6 @@ class Meta(NetBoxTable.Meta): "type", "rule_count", "default_action", - "tags", ) @@ -114,13 +113,12 @@ class Meta(NetBoxTable.Meta): "type", "assigned_object", "direction", - "tags", ) -class ACLStandardRuleTable(NetBoxTable): +class ACLRuleTable(NetBoxTable): """ - Defines the table view for the ACLStandardRule model. + Abstract table for all ACL rules. """ access_list = tables.Column( @@ -130,9 +128,6 @@ class ACLStandardRuleTable(NetBoxTable): linkify=True, ) action = columns.ChoiceFieldColumn() - tags = columns.TagColumn( - url_name="plugins:netbox_acls:aclstandardrule_list", - ) # Source source_type = columns.ContentTypeColumn( @@ -145,7 +140,6 @@ class ACLStandardRuleTable(NetBoxTable): ) class Meta(NetBoxTable.Meta): - model = ACLStandardRule fields = ( "pk", "id", @@ -156,6 +150,7 @@ class Meta(NetBoxTable.Meta): "tags", "description", "source", + "source_type", ) default_columns = ( "access_list", @@ -163,35 +158,33 @@ class Meta(NetBoxTable.Meta): "action", "remark", "source", - "tags", ) -class ACLExtendedRuleTable(NetBoxTable): +class ACLStandardRuleTable(ACLRuleTable): """ - Defines the table view for the ACLExtendedRule model. + Defines the table view for the ACLStandardRule model. """ - access_list = tables.Column( - linkify=True, - ) - index = tables.Column( - linkify=True, - ) - action = columns.ChoiceFieldColumn() tags = columns.TagColumn( - url_name="plugins:netbox_acls:aclextendedrule_list", + url_name="plugins:netbox_acls:aclstandardrule_list", ) + + class Meta(ACLRuleTable.Meta): + model = ACLStandardRule + + +class ACLExtendedRuleTable(ACLRuleTable): + """ + Defines the table view for the ACLExtendedRule model. + """ + protocol = columns.ChoiceFieldColumn() # Source - source_type = columns.ContentTypeColumn( - verbose_name=_("Source Type"), - ) - source = tables.Column( - verbose_name=_("Source"), - orderable=False, - linkify=True, + source_ports = columns.ArrayColumn( + verbose_name=_("Source Ports"), + empty_values=([],), ) # Destination @@ -203,21 +196,22 @@ class ACLExtendedRuleTable(NetBoxTable): orderable=False, linkify=True, ) + destination_ports = columns.ArrayColumn( + verbose_name=_("Destination Ports"), + empty_values=([],), + ) - class Meta(NetBoxTable.Meta): + tags = columns.TagColumn( + url_name="plugins:netbox_acls:aclextendedrule_list", + ) + + class Meta(ACLRuleTable.Meta): model = ACLExtendedRule fields = ( - "pk", - "id", - "access_list", - "index", - "action", - "remark", - "tags", - "description", - "source", + *(ACLRuleTable.Meta.fields), "source_ports", "destination", + "destination_type", "destination_ports", "protocol", ) @@ -231,5 +225,4 @@ class Meta(NetBoxTable.Meta): "source_ports", "destination", "destination_ports", - "tags", )