Skip to content

Commit 4311869

Browse files
committed
Replace custom_object_type.name with custom_object_type.slug in several resolvers
1 parent 628528a commit 4311869

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

netbox_custom_objects/api/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CustomObjectViewSet(ModelViewSet):
2323

2424
def get_view_name(self):
2525
if self.model:
26-
return self.model.custom_object_type.verbose_name or self.model.custom_object_type.name
26+
return self.model.custom_object_type.display_name
2727
return 'Custom Object'
2828

2929
def get_serializer_class(self):

netbox_custom_objects/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def display_name(self):
395395
@staticmethod
396396
def get_content_type_label(custom_object_type_id):
397397
custom_object_type = CustomObjectType.objects.get(pk=custom_object_type_id)
398-
return f"Custom Objects > {custom_object_type.name}"
398+
return f"Custom Objects > {custom_object_type.display_name}"
399399

400400
def register_custom_object_search_index(self, model):
401401
# model must be an instance of this CustomObjectType's get_model() generated class

netbox_custom_objects/templates/netbox_custom_objects/customobject.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{% endblock breadcrumbs %}
2020

2121
{% block object_identifier %}
22-
{{ object|meta:"app_label" }}.{{ object.custom_object_type.name }}:{{ object.pk }}
22+
{{ object|meta:"app_label" }}.{{ object.custom_object_type.slug }}:{{ object.pk }}
2323
{% if object.slug %}({{ object.slug }}){% endif %}
2424
{% endblock object_identifier %}
2525

@@ -74,10 +74,10 @@
7474
<a class="nav-link{% if not tab %} active{% endif %}" href="{{ object.get_absolute_url }}">{{ object.custom_object_type.get_verbose_name }}</a>
7575
</li>
7676
<li class="nav-item">
77-
<a class="nav-link{% if tab == 'journal' %} active{% endif %}" href="{% url 'plugins:netbox_custom_objects:customobject_journal' object.custom_object_type.name object.pk %}">{% trans "Journal" %}</a>
77+
<a class="nav-link{% if tab == 'journal' %} active{% endif %}" href="{% url 'plugins:netbox_custom_objects:customobject_journal' object.custom_object_type.slug object.pk %}">{% trans "Journal" %}</a>
7878
</li>
7979
<li class="nav-item">
80-
<a class="nav-link{% if tab == 'changelog' %} active{% endif %}" href="{% url 'plugins:netbox_custom_objects:customobject_changelog' object.custom_object_type.name object.pk %}">{% trans "Changelog" %}</a>
80+
<a class="nav-link{% if tab == 'changelog' %} active{% endif %}" href="{% url 'plugins:netbox_custom_objects:customobject_changelog' object.custom_object_type.slug object.pk %}">{% trans "Changelog" %}</a>
8181
</li>
8282
</ul>
8383
{% endblock tabs %}

netbox_custom_objects/templatetags/custom_object_buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def custom_object_import_button(model, custom_object_type, action="bulk_import")
207207
try:
208208
viewname = get_viewname(model, action)
209209
url = reverse(
210-
viewname, kwargs={"custom_object_type": custom_object_type.name.lower()}
210+
viewname, kwargs={"custom_object_type": custom_object_type.slug}
211211
)
212212
except NoReverseMatch:
213213
url = None

netbox_custom_objects/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def get_return_url(self):
5555
return reverse(
5656
"plugins:netbox_custom_objects:customobject_journal",
5757
kwargs={
58-
"custom_object_type": self.custom_object.custom_object_type.name,
58+
"custom_object_type": self.custom_object.custom_object_type.slug,
5959
"pk": self.custom_object.pk,
6060
},
6161
)
@@ -81,7 +81,7 @@ def get_return_url(self, request, instance):
8181
return reverse(
8282
"plugins:netbox_custom_objects:customobject_journal",
8383
kwargs={
84-
"custom_object_type": instance.assigned_object.custom_object_type.name,
84+
"custom_object_type": instance.assigned_object.custom_object_type.slug,
8585
"pk": instance.assigned_object.pk,
8686
},
8787
)
@@ -555,7 +555,7 @@ def get_return_url(self, request, obj=None):
555555
"""
556556
if obj:
557557
# Get the custom object type from the object directly
558-
custom_object_type = obj.custom_object_type.name
558+
custom_object_type = obj.custom_object_type.slug
559559
else:
560560
# Fallback to getting it from kwargs if object is not available
561561
custom_object_type = self.kwargs.get("custom_object_type")

0 commit comments

Comments
 (0)