mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-18 19:32:24 -06:00
Merge branch 'develop' into 3919-utilization-bar-width
This commit is contained in:
@@ -38,11 +38,18 @@ class ComponentTemplateModel(models.Model):
|
||||
raise NotImplementedError()
|
||||
|
||||
def to_objectchange(self, action):
|
||||
# Annotate the parent DeviceType
|
||||
try:
|
||||
parent = getattr(self, 'device_type', None)
|
||||
except ObjectDoesNotExist:
|
||||
# The parent DeviceType has already been deleted
|
||||
parent = None
|
||||
|
||||
return ObjectChange(
|
||||
changed_object=self,
|
||||
object_repr=str(self),
|
||||
action=action,
|
||||
related_object=self.device_type,
|
||||
related_object=parent,
|
||||
object_data=serialize_object(self)
|
||||
)
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from django.urls import reverse
|
||||
from django.utils.encoding import force_bytes
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
from dcim.models import Device
|
||||
from extras.models import CustomFieldModel, TaggedItem
|
||||
from utilities.models import ChangeLoggedModel
|
||||
from .exceptions import InvalidKey
|
||||
@@ -359,10 +360,14 @@ class Secret(ChangeLoggedModel, CustomFieldModel):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
if self.role and self.device and self.name:
|
||||
try:
|
||||
device = self.device
|
||||
except Device.DoesNotExist:
|
||||
device = None
|
||||
if self.role and device and self.name:
|
||||
return '{} for {} ({})'.format(self.role, self.device, self.name)
|
||||
# Return role and device if no name is set
|
||||
if self.role and self.device:
|
||||
if self.role and device:
|
||||
return '{} for {}'.format(self.role, self.device)
|
||||
return 'Secret'
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<li><a href="{{ objectchange.related_object.get_absolute_url }}changelog/">{{ objectchange.related_object }}</a></li>
|
||||
{% elif objectchange.changed_object.get_absolute_url %}
|
||||
<li><a href="{{ objectchange.changed_object.get_absolute_url }}changelog/">{{ objectchange.changed_object }}</a></li>
|
||||
{% else %}
|
||||
{% elif objectchange.changed_object %}
|
||||
<li>{{ objectchange.changed_object }}</li>
|
||||
{% endif %}
|
||||
<li>{{ objectchange }}</li>
|
||||
@@ -97,7 +97,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{% include 'panel_table.html' with table=related_changes_table heading='Related Changes' panel_class='noprint' %}
|
||||
{% include 'panel_table.html' with table=related_changes_table heading='Related Changes' panel_class='default' %}
|
||||
{% if related_changes_count > related_changes_table.rows|length %}
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'extras:objectchange_list' %}?request_id={{ objectchange.request_id }}" class="btn btn-primary">See all {{ related_changes_count|add:"1" }} changes</a>
|
||||
|
||||
Reference in New Issue
Block a user