|
@@ -256,13 +256,15 @@ class RelatedObjectAttr(ObjectAttribute):
|
|
|
linkify (bool): If True, the rendered value will be hyperlinked to the related object's detail view
|
|
linkify (bool): If True, the rendered value will be hyperlinked to the related object's detail view
|
|
|
grouped_by (str): A second-order object to annotate alongside the related object; for example, an attribute
|
|
grouped_by (str): A second-order object to annotate alongside the related object; for example, an attribute
|
|
|
representing the dcim.Site model might specify grouped_by="region"
|
|
representing the dcim.Site model might specify grouped_by="region"
|
|
|
|
|
+ colored (bool): If True, render the object as a colored badge when it exposes a `color` attribute
|
|
|
"""
|
|
"""
|
|
|
template_name = 'ui/attrs/object.html'
|
|
template_name = 'ui/attrs/object.html'
|
|
|
|
|
|
|
|
- def __init__(self, *args, linkify=None, grouped_by=None, **kwargs):
|
|
|
|
|
|
|
+ def __init__(self, *args, linkify=None, grouped_by=None, colored=False, **kwargs):
|
|
|
super().__init__(*args, **kwargs)
|
|
super().__init__(*args, **kwargs)
|
|
|
self.linkify = linkify
|
|
self.linkify = linkify
|
|
|
self.grouped_by = grouped_by
|
|
self.grouped_by = grouped_by
|
|
|
|
|
+ self.colored = colored
|
|
|
|
|
|
|
|
def get_context(self, obj, context):
|
|
def get_context(self, obj, context):
|
|
|
value = self.get_value(obj)
|
|
value = self.get_value(obj)
|
|
@@ -270,6 +272,7 @@ class RelatedObjectAttr(ObjectAttribute):
|
|
|
return {
|
|
return {
|
|
|
'linkify': self.linkify,
|
|
'linkify': self.linkify,
|
|
|
'group': group,
|
|
'group': group,
|
|
|
|
|
+ 'colored': self.colored,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -327,6 +330,7 @@ class RelatedObjectListAttr(RelatedObjectAttr):
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
'linkify': self.linkify,
|
|
'linkify': self.linkify,
|
|
|
|
|
+ 'colored': self.colored,
|
|
|
'items': [
|
|
'items': [
|
|
|
{
|
|
{
|
|
|
'value': item,
|
|
'value': item,
|
|
@@ -358,13 +362,15 @@ class NestedObjectAttr(ObjectAttribute):
|
|
|
Parameters:
|
|
Parameters:
|
|
|
linkify (bool): If True, the rendered value will be hyperlinked to the related object's detail view
|
|
linkify (bool): If True, the rendered value will be hyperlinked to the related object's detail view
|
|
|
max_depth (int): Maximum number of ancestors to display (default: all)
|
|
max_depth (int): Maximum number of ancestors to display (default: all)
|
|
|
|
|
+ colored (bool): If True, render the object as a colored badge when it exposes a `color` attribute
|
|
|
"""
|
|
"""
|
|
|
template_name = 'ui/attrs/nested_object.html'
|
|
template_name = 'ui/attrs/nested_object.html'
|
|
|
|
|
|
|
|
- def __init__(self, *args, linkify=None, max_depth=None, **kwargs):
|
|
|
|
|
|
|
+ def __init__(self, *args, linkify=None, max_depth=None, colored=False, **kwargs):
|
|
|
super().__init__(*args, **kwargs)
|
|
super().__init__(*args, **kwargs)
|
|
|
self.linkify = linkify
|
|
self.linkify = linkify
|
|
|
self.max_depth = max_depth
|
|
self.max_depth = max_depth
|
|
|
|
|
+ self.colored = colored
|
|
|
|
|
|
|
|
def get_context(self, obj, context):
|
|
def get_context(self, obj, context):
|
|
|
value = self.get_value(obj)
|
|
value = self.get_value(obj)
|
|
@@ -374,6 +380,7 @@ class NestedObjectAttr(ObjectAttribute):
|
|
|
return {
|
|
return {
|
|
|
'nodes': nodes,
|
|
'nodes': nodes,
|
|
|
'linkify': self.linkify,
|
|
'linkify': self.linkify,
|
|
|
|
|
+ 'colored': self.colored,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|