Floor plans get an optional tenant (inherited from location or site on creation; existing plans are pre-filled by the migration). The list view supports tenant and tenant group filtering and columns, and the tenant is exposed in forms, CSV import, REST API and the detail page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
import django_tables2 as tables
|
|
from django.utils.translation import gettext_lazy as _
|
|
from netbox.tables import NetBoxTable, columns
|
|
from tenancy.tables import TenancyColumnsMixin
|
|
|
|
from .models import FloorPlan
|
|
from .utils import format_room_size
|
|
|
|
__all__ = ('FloorPlanTable',)
|
|
|
|
|
|
class FloorPlanTable(TenancyColumnsMixin, NetBoxTable):
|
|
name = tables.Column(verbose_name=_('Name'), linkify=True)
|
|
site = tables.Column(verbose_name=_('Site'), linkify=True)
|
|
location = tables.Column(verbose_name=_('Location'), linkify=True)
|
|
room_size = tables.Column(verbose_name=_('Room size (m)'), empty_values=(), orderable=False)
|
|
width = tables.Column(verbose_name=_('Width (cm)'))
|
|
depth = tables.Column(verbose_name=_('Depth (cm)'))
|
|
item_count = tables.Column(verbose_name=_('Items'))
|
|
rack_count = tables.Column(verbose_name=_('Racks'))
|
|
tags = columns.TagColumn(url_name='plugins:netbox_floorplanner:floorplan_list')
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
model = FloorPlan
|
|
fields = (
|
|
'pk', 'id', 'name', 'site', 'location', 'tenant', 'tenant_group', 'room_size', 'width', 'depth', 'grid_size', 'item_count',
|
|
'rack_count', 'description', 'tags', 'created', 'last_updated',
|
|
)
|
|
default_columns = ('name', 'site', 'location', 'tenant', 'room_size', 'rack_count', 'description')
|
|
|
|
def render_room_size(self, record):
|
|
return f'{format_room_size(record.width, record.depth)} m'
|