99from netbox .tables import NetBoxTable , columns
1010from utilities .permissions import get_permission_for_model
1111
12+ from netbox_custom_objects .constants import APP_LABEL
1213from netbox_custom_objects .models import CustomObject , CustomObjectType
1314from netbox_custom_objects .utilities import get_viewname
1415
@@ -56,7 +57,7 @@ class CustomObjectTypeTable(NetBoxTable):
5657 verbose_name = _ ('Comments' ),
5758 )
5859 tags = columns .TagColumn (
59- url_name = 'circuits:provider_list '
60+ url_name = 'plugins:netbox_custom_objects:customobjecttype_list '
6061 )
6162 name = tables .Column (
6263 verbose_name = _ ('Name' ),
@@ -87,6 +88,31 @@ class Meta(NetBoxTable.Meta):
8788 )
8889
8990
91+ class CustomObjectTagColumn (columns .TagColumn ):
92+ """
93+ Custom TagColumn that generates tag filter URLs with the custom_object_type slug.
94+ """
95+ template_code = """
96+ {% load helpers %}
97+ {% for tag in value.all %}
98+ <a href="{% url 'plugins:netbox_custom_objects:customobject_list' custom_object_type=record.custom_object_type.slug %}?tag={{ tag.slug }}">
99+ <span {% if tag.description %}title="{{ tag.description }}"{% endif %} class="badge" style="color: {{ tag.color|fgcolor }}; background-color: #{{ tag.color }}">{{ tag }}</span>
100+ </a>
101+ {% empty %}
102+ <span class="text-muted">—</span>
103+ {% endfor %}
104+ """
105+
106+ def __init__ (self ):
107+ # Override parent __init__ to use our custom template
108+ tables .TemplateColumn .__init__ (
109+ self ,
110+ orderable = False ,
111+ template_code = self .template_code ,
112+ verbose_name = _ ('Tags' ),
113+ )
114+
115+
90116class CustomObjectActionsColumn (columns .ActionsColumn ):
91117
92118 def render (self , record , table , ** kwargs ):
@@ -178,6 +204,7 @@ class CustomObjectTable(NetBoxTable):
178204 actions = CustomObjectActionsColumn (
179205 actions = ('edit' , 'delete' ),
180206 )
207+ tags = CustomObjectTagColumn ()
181208
182209 class Meta (NetBoxTable .Meta ):
183210 model = CustomObject
@@ -188,6 +215,7 @@ class Meta(NetBoxTable.Meta):
188215 "custom_object_type" ,
189216 "created" ,
190217 "last_updated" ,
218+ "tags" ,
191219 )
192220 default_columns = (
193221 "pk" ,
0 commit comments