Add tenant to floor plans with tenant filters
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]>
This commit is contained in:
1 parent
805aedba52
commit
04a6e16975
16 files changed
+87
-16
No files matched your search
@@ -1,6 +1,7 @@
|
||||
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
|
||||
@@ -8,7 +9,7 @@ from .utils import format_room_size
|
||||
__all__ = ('FloorPlanTable',)
|
||||
|
||||
|
||||
class FloorPlanTable(NetBoxTable):
|
||||
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)
|
||||
@@ -22,10 +23,10 @@ class FloorPlanTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = FloorPlan
|
||||
fields = (
|
||||
'pk', 'id', 'name', 'site', 'location', 'room_size', 'width', 'depth', 'grid_size', 'item_count',
|
||||
'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', 'room_size', 'rack_count', 'description')
|
||||
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'
|
||||
Reference in new issue
Block a user