Include attributes column for profiles

This commit is contained in:
Jeremy Stretch 2025-03-28 15:21:21 -04:00
parent 1be9209b04
commit 9f16e434f7
2 changed files with 12 additions and 2 deletions

View File

@ -3,7 +3,7 @@ import django_tables2 as tables
from dcim.models import Module, ModuleType, ModuleTypeProfile
from netbox.tables import NetBoxTable, columns
from .template_code import WEIGHT
from .template_code import MODULETYPEPROFILE_ATTRIBUTES, WEIGHT
__all__ = (
'ModuleTable',
@ -17,6 +17,12 @@ class ModuleTypeProfileTable(NetBoxTable):
verbose_name=_('Name'),
linkify=True
)
attributes = columns.TemplateColumn(
template_code=MODULETYPEPROFILE_ATTRIBUTES,
accessor=tables.A('schema__properties'),
orderable=False,
verbose_name=_('Attributes')
)
comments = columns.MarkdownColumn(
verbose_name=_('Comments'),
)
@ -30,7 +36,7 @@ class ModuleTypeProfileTable(NetBoxTable):
'pk', 'id', 'name', 'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = (
'pk', 'name', 'description',
'pk', 'name', 'description', 'attributes',
)

View File

@ -568,3 +568,7 @@ MODULEBAY_BUTTONS = """
{% endif %}
{% endif %}
"""
MODULETYPEPROFILE_ATTRIBUTES = """
{% if value %}{% for attr in value %}{{ attr }}{% if not forloop.last %}, {% endif %}{% endfor %}{% endif %}
"""