1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #8763: Fix inventory item component assignment

This commit is contained in:
jeremystretch
2022-03-03 11:52:36 -05:00
parent e6072a51f8
commit 62a1d4b3e0
6 changed files with 31 additions and 11 deletions

View File

@ -155,6 +155,7 @@ Where it is desired to limit the range of available VLANs within a group, users
* [#8682](https://github.com/netbox-community/netbox/issues/8682) - Limit available VLANs by group min/max VIDs * [#8682](https://github.com/netbox-community/netbox/issues/8682) - Limit available VLANs by group min/max VIDs
* [#8683](https://github.com/netbox-community/netbox/issues/8683) - Fix `ZoneInfoNotFoundError` exception under Python 3.9+ * [#8683](https://github.com/netbox-community/netbox/issues/8683) - Fix `ZoneInfoNotFoundError` exception under Python 3.9+
* [#8761](https://github.com/netbox-community/netbox/issues/8761) - Correct view name resolution under journal entry views * [#8761](https://github.com/netbox-community/netbox/issues/8761) - Correct view name resolution under journal entry views
* [#8763](https://github.com/netbox-community/netbox/issues/8763) - Fix inventory item component assignment
* [#8764](https://github.com/netbox-community/netbox/issues/8764) - Correct view name resolution for dynamic form fields * [#8764](https://github.com/netbox-community/netbox/issues/8764) - Correct view name resolution for dynamic form fields
### Other Changes ### Other Changes

View File

@ -113,7 +113,7 @@ MODULAR_COMPONENT_TEMPLATE_BUTTONS = """
CONSOLEPORT_BUTTONS = """ CONSOLEPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %} {% if perms.dcim.add_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ object.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item"> <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
</a> </a>
{% endif %} {% endif %}
@ -145,7 +145,7 @@ CONSOLEPORT_BUTTONS = """
CONSOLESERVERPORT_BUTTONS = """ CONSOLESERVERPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %} {% if perms.dcim.add_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ object.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item"> <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
</a> </a>
{% endif %} {% endif %}
@ -177,7 +177,7 @@ CONSOLESERVERPORT_BUTTONS = """
POWERPORT_BUTTONS = """ POWERPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %} {% if perms.dcim.add_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ object.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item"> <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
</a> </a>
{% endif %} {% endif %}
@ -208,7 +208,7 @@ POWERPORT_BUTTONS = """
POWEROUTLET_BUTTONS = """ POWEROUTLET_BUTTONS = """
{% if perms.dcim.add_inventoryitem %} {% if perms.dcim.add_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ object.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item"> <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
</a> </a>
{% endif %} {% endif %}
@ -236,7 +236,7 @@ POWEROUTLET_BUTTONS = """
INTERFACE_BUTTONS = """ INTERFACE_BUTTONS = """
{% if perms.ipam.add_ipaddress or perms.dcim.add_inventoryitem %} {% if perms.ipam.add_ipaddress or perms.dcim.add_inventoryitem %}
<span class="dropdown"> <span class="dropdown">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Add"> <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Add">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
</button> </button>
<ul class="dropdown-menu dropdown-menu-end"> <ul class="dropdown-menu dropdown-menu-end">
@ -244,7 +244,7 @@ INTERFACE_BUTTONS = """
<li><a class="dropdown-item" href="{% url 'ipam:ipaddress_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">IP Address</a></li> <li><a class="dropdown-item" href="{% url 'ipam:ipaddress_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">IP Address</a></li>
{% endif %} {% endif %}
{% if perms.dcim.add_inventoryitem %} {% if perms.dcim.add_inventoryitem %}
<li><a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ object.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Inventory Item</a></li> <li><a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Inventory Item</a></li>
{% endif %} {% endif %}
</ul> </ul>
</span> </span>
@ -292,7 +292,7 @@ INTERFACE_BUTTONS = """
FRONTPORT_BUTTONS = """ FRONTPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %} {% if perms.dcim.add_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ object.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item"> <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
</a> </a>
{% endif %} {% endif %}
@ -329,7 +329,7 @@ FRONTPORT_BUTTONS = """
REARPORT_BUTTONS = """ REARPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %} {% if perms.dcim.add_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ object.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item"> <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
</a> </a>
{% endif %} {% endif %}

View File

@ -1397,7 +1397,7 @@ class InventoryItemTemplateCreateView(generic.ComponentCreateView):
queryset = InventoryItemTemplate.objects.all() queryset = InventoryItemTemplate.objects.all()
form = forms.ModularComponentTemplateCreateForm form = forms.ModularComponentTemplateCreateForm
model_form = forms.InventoryItemTemplateForm model_form = forms.InventoryItemTemplateForm
template_name = 'dcim/inventoryitem_create.html' template_name = 'dcim/inventoryitemtemplate_create.html'
def alter_object(self, instance, request): def alter_object(self, instance, request):
# Set component (if any) # Set component (if any)

View File

@ -2,6 +2,8 @@
{% load form_helpers %} {% load form_helpers %}
{% block form %} {% block form %}
{% render_form replication_form %} {% block replication_fields %}
{% render_form replication_form %}
{% endblock replication_fields %}
{{ block.super }} {{ block.super }}
{% endblock form %} {% endblock form %}

View File

@ -1,4 +1,4 @@
{% extends 'dcim/component_template_create.html' %} {% extends 'dcim/component_create.html' %}
{% load helpers %} {% load helpers %}
{% load form_helpers %} {% load form_helpers %}

View File

@ -0,0 +1,17 @@
{% extends 'dcim/component_template_create.html' %}
{% load helpers %}
{% load form_helpers %}
{% block replication_fields %}
{{ block.super }}
{% if object.component %}
<div class="row mb-3">
<label class="col-sm-3 col-form-label text-lg-end">
{{ object.component|meta:"verbose_name"|bettertitle }}
</label>
<div class="col">
<input class="form-control" value="{{ object.component }}" disabled />
</div>
</div>
{% endif %}
{% endblock replication_fields %}