mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Introduced ability to manually create Modules
This commit is contained in:
parent
4b34af3e1d
commit
7428b83c90
@ -142,6 +142,7 @@ urlpatterns = [
|
|||||||
url(r'^interfaces/(?P<pk>\d+)/delete/$', views.interface_delete, name='interface_delete'),
|
url(r'^interfaces/(?P<pk>\d+)/delete/$', views.interface_delete, name='interface_delete'),
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
|
url(r'^devices/(?P<pk>\d+)/modules/add/$', views.module_add, name='module_add'),
|
||||||
url(r'^modules/(?P<pk>\d+)/edit/$', views.module_edit, name='module_edit'),
|
url(r'^modules/(?P<pk>\d+)/edit/$', views.module_edit, name='module_edit'),
|
||||||
url(r'^modules/(?P<pk>\d+)/delete/$', views.module_delete, name='module_delete'),
|
url(r'^modules/(?P<pk>\d+)/delete/$', views.module_delete, name='module_delete'),
|
||||||
|
|
||||||
|
@ -1503,6 +1503,31 @@ def ipaddress_assign(request, pk):
|
|||||||
# Modules
|
# Modules
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@permission_required('dcim.add_module')
|
||||||
|
def module_add(request, pk):
|
||||||
|
|
||||||
|
device = get_object_or_404(Device, pk=pk)
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = forms.ModuleForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
module = form.save(commit=False)
|
||||||
|
module.device = device
|
||||||
|
module.save()
|
||||||
|
messages.success(request, "Added module {} to {}".format(module.name, module.device.name))
|
||||||
|
return redirect('dcim:device_inventory', pk=module.device.pk)
|
||||||
|
|
||||||
|
else:
|
||||||
|
form = forms.ModuleForm()
|
||||||
|
|
||||||
|
return render(request, 'dcim/module_edit.html', {
|
||||||
|
'device': device,
|
||||||
|
'form': form,
|
||||||
|
'cancel_url': reverse('dcim:device_inventory', kwargs={'pk': device.pk}),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@permission_required('dcim.change_module')
|
@permission_required('dcim.change_module')
|
||||||
def module_edit(request, pk):
|
def module_edit(request, pk):
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
<table class="table table-hover table-condensed panel-body" id="hardware">
|
<table class="table table-hover table-condensed panel-body" id="hardware">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
|
||||||
<th>Module</th>
|
<th>Module</th>
|
||||||
|
<th></th>
|
||||||
<th>Part Number</th>
|
<th>Part Number</th>
|
||||||
<th>Serial Number</th>
|
<th>Serial Number</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
@ -55,8 +55,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for m in modules %}
|
{% for m in modules %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if not m.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
|
||||||
<td>{{ m.name }}</td>
|
<td>{{ m.name }}</td>
|
||||||
|
<td>{% if not m.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
||||||
<td>{{ m.part_id }}</td>
|
<td>{{ m.part_id }}</td>
|
||||||
<td>{{ m.serial }}</td>
|
<td>{{ m.serial }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -70,8 +70,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for m2 in m.submodules.all %}
|
{% for m2 in m.submodules.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if not m.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
|
||||||
<td style="padding-left: 20px">{{ m2.name }}</td>
|
<td style="padding-left: 20px">{{ m2.name }}</td>
|
||||||
|
<td>{% if not m2.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
||||||
<td>{{ m2.part_id }}</td>
|
<td>{{ m2.part_id }}</td>
|
||||||
<td>{{ m2.serial }}</td>
|
<td>{{ m2.serial }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -85,8 +85,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for m3 in m2.submodules.all %}
|
{% for m3 in m2.submodules.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if not m.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
|
||||||
<td style="padding-left: 40px">{{ m3.name }}</td>
|
<td style="padding-left: 40px">{{ m3.name }}</td>
|
||||||
|
<td>{% if not m3.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
||||||
<td>{{ m3.part_id }}</td>
|
<td>{{ m3.part_id }}</td>
|
||||||
<td>{{ m3.serial }}</td>
|
<td>{{ m3.serial }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -100,8 +100,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for m4 in m3.submodules.all %}
|
{% for m4 in m3.submodules.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if not m.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
|
||||||
<td style="padding-left: 60px">{{ m4.name }}</td>
|
<td style="padding-left: 60px">{{ m4.name }}</td>
|
||||||
|
<td>{% if not m4.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
||||||
<td>{{ m4.part_id }}</td>
|
<td>{{ m4.part_id }}</td>
|
||||||
<td>{{ m4.serial }}</td>
|
<td>{{ m4.serial }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -120,6 +120,12 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{% if perms.dcim.add_module %}
|
||||||
|
<a href="{% url 'dcim:module_add' pk=device.pk %}" class="btn btn-success">
|
||||||
|
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||||
|
Add a Module
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
{% load form_helpers %}
|
{% load form_helpers %}
|
||||||
|
|
||||||
{% block title %}Editing {{ module.device }} {{ module }}{% endblock %}
|
{% block title %}{% if module %}Editing {{ module.device }} {{ module }}{% else %}Add a Module to {{ device }}{% endif %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<form action="." method="post" class="form form-horizontal">
|
<form action="." method="post" class="form form-horizontal">
|
||||||
@ -18,13 +18,13 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<strong>Editing {{ module.device }} {{ module }}</strong>
|
<strong>{% if module %}Editing {{ module.device }} {{ module }}{% else %}Add a Module to {{ device }}{% endif %}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-3 control-label required">Device</label>
|
<label class="col-md-3 control-label required">Device</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<p class="form-control-static">{{ module.device }}</p>
|
<p class="form-control-static">{% if module %}{{ module.device }}{% else %}{{ device }}{% endif %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% render_form form %}
|
{% render_form form %}
|
||||||
|
Loading…
Reference in New Issue
Block a user