Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions netbox_custom_objects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def get_absolute_url(self):
},
)

def get_list_url(self):
return reverse(
"plugins:netbox_custom_objects:customobject_list",
kwargs={"custom_object_type": self.custom_object_type.name.lower()},
)


class CustomObjectType(NetBoxModel):
# Class-level cache for generated models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,59 @@
{% block extra_controls %}
{% endblock %}

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

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

{# Controls #}
<div class="d-print-none">
{% block controls %}
<div class="btn-list">
{% block control-buttons %}
{# Default buttons #}
{% if perms.extras.add_bookmark and object.bookmarks %}
{% custom_object_bookmark_button object %}
{% endif %}
{% if perms.extras.add_subscription and object.subscriptions %}
{% custom_object_subscribe_button object %}
{% endif %}
{% if request.user|can_add:object %}
{% custom_object_clone_button object %}
{% endif %}
{% if request.user|can_change:object %}
{% custom_object_edit_button object %}
{% endif %}
{% if request.user|can_delete:object %}
{% custom_object_delete_button object %}
{% endif %}
{% endblock %}
</div>
{% block title %}{{ object }}{% endblock title %}

{# Custom links #}
<div class="d-flex justify-content-end">
<div class="btn-list">
{% block custom-links %}
{% custom_links object %}
{% endblock custom-links %}
</div>
</div>

{% endblock controls %}
</div>
{% block subtitle %}
<div class="text-secondary fs-5">
{% trans "Created" %} {{ object.created|isodatetime:"minutes" }}
{% if object.last_updated %}
<span class="separator">&middot;</span>
{% trans "Updated" %} {{ object.last_updated|isodatetime:"minutes" }}
{% endif %}
</div>
{% endblock subtitle %}

{% block controls %}
<div class="btn-list justify-content-end mb-2">
{% block control-buttons %}
{# Default buttons #}
{% if perms.extras.add_bookmark and object.bookmarks %}
{% custom_object_bookmark_button object %}
{% endif %}
{% if perms.extras.add_subscription and object.subscriptions %}
{% custom_object_subscribe_button object %}
{% endif %}
{% if request.user|can_add:object %}
{% custom_object_clone_button object %}
{% endif %}
{% if request.user|can_change:object %}
{% custom_object_edit_button object %}
{% endif %}
{% if request.user|can_delete:object %}
{% custom_object_delete_button object %}
{% endif %}
{% endblock %}
</div>
</div>
{% endblock %}

{# Custom links #}
<div class="d-flex justify-content-end">
<div class="btn-list">
{% block custom-links %}
{% custom_links object %}
{% endblock custom-links %}
</div>
</div>
{% endblock controls %}

{% block tabs %}
<ul class="nav nav-tabs" role="presentation">
Expand Down