mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
refactored region hierarchy #13735
This commit is contained in:
parent
f615eec28c
commit
d97449560f
@ -1,5 +1,6 @@
|
|||||||
from django import template
|
from django import template
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
from dcim.models import Site
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@ -10,6 +11,9 @@ def display_region(context, obj):
|
|||||||
Renders hierarchical region data for a given object.
|
Renders hierarchical region data for a given object.
|
||||||
"""
|
"""
|
||||||
# Retrieve the region or site information
|
# Retrieve the region or site information
|
||||||
|
if isinstance(obj, Site):
|
||||||
|
region = obj.region
|
||||||
|
else:
|
||||||
region = getattr(obj, 'region', None) or getattr(obj.site, 'region', None)
|
region = getattr(obj, 'region', None) or getattr(obj.site, 'region', None)
|
||||||
|
|
||||||
# Return a placeholder if no region or site is found
|
# Return a placeholder if no region or site is found
|
||||||
|
Loading…
Reference in New Issue
Block a user