Files
NetBox-FloorPlan2.0/netbox_floorplanner/template_content.py
T
MrBlakeandClaude Opus 5.5 c4dc5d53ce Initial NetBox Floor Planner plugin
Drag & drop SVG floor plan designer for NetBox 4.7.2+ with rack/device
placement, smart snapping, undo/redo, view mode with status colouring,
SVG/PNG export, REST layout API and English/German translations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:18:13 +01:00

23 lines
786 B
Python

from netbox.plugins import PluginTemplateExtension
from .models import FloorPlanItem
class RackFloorPlanButton(PluginTemplateExtension):
"""Adds a "Show on floor plan" button to racks and devices that are placed on a plan."""
models = ['dcim.rack', 'dcim.device']
def buttons(self):
obj = self.context['object']
field = 'rack' if obj._meta.model_name == 'rack' else 'device'
item = FloorPlanItem.objects.filter(**{field: obj}).select_related('floorplan').first()
if item is None:
return ''
return self.render('netbox_floorplanner/inc/floorplan_button.html', extra_context={
'floorplan': item.floorplan,
'highlight': f'{field}-{obj.pk}',
})
template_extensions = [RackFloorPlanButton]