Skip to content

Commit 11ce9f5

Browse files
authored
NPL-427 fix custom object detail view header (#116)
1 parent 6fff0b6 commit 11ce9f5

File tree

2 files changed

+54
-44
lines changed

2 files changed

+54
-44
lines changed

netbox_custom_objects/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def get_absolute_url(self):
115115
},
116116
)
117117

118+
def get_list_url(self):
119+
return reverse(
120+
"plugins:netbox_custom_objects:customobject_list",
121+
kwargs={"custom_object_type": self.custom_object_type.name.lower()},
122+
)
123+
118124

119125
class CustomObjectType(NetBoxModel):
120126
# Class-level cache for generated models

netbox_custom_objects/templates/netbox_custom_objects/customobject.html

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,59 @@
1313
{% block extra_controls %}
1414
{% endblock %}
1515

16-
{% block page-header %}
17-
<div class="container-fluid mt-2 d-print-none">
18-
<div class="d-flex justify-content-between align-items-center mt-2">
16+
{% block breadcrumbs %}
17+
<li class="breadcrumb-item"><a href="{{ object.get_list_url }}">{{ object.custom_object_type.get_verbose_name_plural }}</a></li>
18+
<li class="breadcrumb-item"><a href="{{ object.custom_object_type.get_absolute_url }}">{{ object.custom_object_type }}</a></li>
19+
{% endblock breadcrumbs %}
1920

20-
{# Title #}
21-
<div>
22-
<h1 class="page-title">{% block title %}{{ object }}{% endblock title %}</h1>
23-
{% block subtitle %}{% endblock %}
24-
</div>
21+
{% block object_identifier %}
22+
{{ object|meta:"app_label" }}.{{ object.custom_object_type.name }}:{{ object.pk }}
23+
{% if object.slug %}({{ object.slug }}){% endif %}
24+
{% endblock object_identifier %}
2525

26-
{# Controls #}
27-
<div class="d-print-none">
28-
{% block controls %}
29-
<div class="btn-list">
30-
{% block control-buttons %}
31-
{# Default buttons #}
32-
{% if perms.extras.add_bookmark and object.bookmarks %}
33-
{% custom_object_bookmark_button object %}
34-
{% endif %}
35-
{% if perms.extras.add_subscription and object.subscriptions %}
36-
{% custom_object_subscribe_button object %}
37-
{% endif %}
38-
{% if request.user|can_add:object %}
39-
{% custom_object_clone_button object %}
40-
{% endif %}
41-
{% if request.user|can_change:object %}
42-
{% custom_object_edit_button object %}
43-
{% endif %}
44-
{% if request.user|can_delete:object %}
45-
{% custom_object_delete_button object %}
46-
{% endif %}
47-
{% endblock %}
48-
</div>
26+
{% block title %}{{ object }}{% endblock title %}
4927

50-
{# Custom links #}
51-
<div class="d-flex justify-content-end">
52-
<div class="btn-list">
53-
{% block custom-links %}
54-
{% custom_links object %}
55-
{% endblock custom-links %}
56-
</div>
57-
</div>
58-
59-
{% endblock controls %}
60-
</div>
28+
{% block subtitle %}
29+
<div class="text-secondary fs-5">
30+
{% trans "Created" %} {{ object.created|isodatetime:"minutes" }}
31+
{% if object.last_updated %}
32+
<span class="separator">&middot;</span>
33+
{% trans "Updated" %} {{ object.last_updated|isodatetime:"minutes" }}
34+
{% endif %}
35+
</div>
36+
{% endblock subtitle %}
6137

38+
{% block controls %}
39+
<div class="btn-list justify-content-end mb-2">
40+
{% block control-buttons %}
41+
{# Default buttons #}
42+
{% if perms.extras.add_bookmark and object.bookmarks %}
43+
{% custom_object_bookmark_button object %}
44+
{% endif %}
45+
{% if perms.extras.add_subscription and object.subscriptions %}
46+
{% custom_object_subscribe_button object %}
47+
{% endif %}
48+
{% if request.user|can_add:object %}
49+
{% custom_object_clone_button object %}
50+
{% endif %}
51+
{% if request.user|can_change:object %}
52+
{% custom_object_edit_button object %}
53+
{% endif %}
54+
{% if request.user|can_delete:object %}
55+
{% custom_object_delete_button object %}
56+
{% endif %}
57+
{% endblock %}
6258
</div>
63-
</div>
64-
{% endblock %}
59+
60+
{# Custom links #}
61+
<div class="d-flex justify-content-end">
62+
<div class="btn-list">
63+
{% block custom-links %}
64+
{% custom_links object %}
65+
{% endblock custom-links %}
66+
</div>
67+
</div>
68+
{% endblock controls %}
6569

6670
{% block tabs %}
6771
<ul class="nav nav-tabs" role="presentation">

0 commit comments

Comments
 (0)