mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 11:26:26 -06:00
Add "Edit" and "Delete" Service port functionality
This commit is contained in:
parent
974d8419e6
commit
81a9e05b62
@ -62,7 +62,9 @@ urlpatterns = [
|
|||||||
|
|
||||||
# Service Ports
|
# Service Ports
|
||||||
url(r'^service-ports/(?P<pk>\d+)/$', views.serviceport, name='serviceport'),
|
url(r'^service-ports/(?P<pk>\d+)/$', views.serviceport, name='serviceport'),
|
||||||
|
url(r'^service-ports/(?P<pk>\d+)/edit/$', views.ServicePortEditView.as_view(), name='serviceport_edit'),
|
||||||
|
url(r'^service-ports/(?P<pk>\d+)/delete/$', views.ServicePortDeleteView.as_view(), name='serviceport_delete'),
|
||||||
|
|
||||||
# VLAN groups
|
# VLAN groups
|
||||||
url(r'^vlan-groups/$', views.VLANGroupListView.as_view(), name='vlangroup_list'),
|
url(r'^vlan-groups/$', views.VLANGroupListView.as_view(), name='vlangroup_list'),
|
||||||
url(r'^vlan-groups/add/$', views.VLANGroupEditView.as_view(), name='vlangroup_add'),
|
url(r'^vlan-groups/add/$', views.VLANGroupEditView.as_view(), name='vlangroup_add'),
|
||||||
|
@ -657,6 +657,35 @@ def serviceport(request, pk):
|
|||||||
'service_port': service_port,
|
'service_port': service_port,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class ServicePortEditView(PermissionRequiredMixin, ObjectEditView):
|
||||||
|
permission_required = 'ipam.change_ipaddress'
|
||||||
|
model = ServicePort
|
||||||
|
form_class = forms.ServicePortForm
|
||||||
|
fields_initial = ['ip_address', 'port' 'type', 'name', 'description']
|
||||||
|
template_name = 'ipam/serviceport_edit.html'
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
service_port = self.get_object(kwargs)
|
||||||
|
device_url = reverse('dcim:device', kwargs={'pk': service_port.ip_address.device.pk})
|
||||||
|
self.success_url = device_url
|
||||||
|
self.cancel_url = device_url
|
||||||
|
|
||||||
|
return super(ServicePortEditView, self).post(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class ServicePortDeleteView(PermissionRequiredMixin, ObjectDeleteView):
|
||||||
|
permission_required = 'ipam.delete_ipaddress'
|
||||||
|
model = ServicePort
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
service_port = self.get_object(kwargs)
|
||||||
|
self.redirect_url = reverse('dcim:device', kwargs={'pk': service_port.ip_address.device.pk})
|
||||||
|
|
||||||
|
return super(ServicePortDeleteView, self).post(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
# VLAN groups
|
# VLAN groups
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -14,4 +14,16 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
<td class="text-right">
|
||||||
|
{% if perms.ipam.change_ipaddress %}
|
||||||
|
<a href="{% url 'ipam:serviceport_edit' pk=port.pk %}" class="btn btn-info btn-xs" title="Edit service port">
|
||||||
|
<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if perms.ipam.delete_ipaddress %}
|
||||||
|
<a href="{% url 'ipam:serviceport_delete' pk=port.pk %}" class="btn btn-danger btn-xs">
|
||||||
|
<i class="glyphicon glyphicon-trash" aria-hidden="true" title="Delete port"></i>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
76
netbox/templates/ipam/serviceport.html
Normal file
76
netbox/templates/ipam/serviceport.html
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
{% extends '_base.html' %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
|
{% block title %}{{ ipaddress }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li>Service Ports</li>
|
||||||
|
<li>{{ service_port }}</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
{% if perms.ipam.change_ipaddress %}
|
||||||
|
<a href="{% url 'ipam:serviceport_edit' pk=service_port.pk %}" class="btn btn-warning">
|
||||||
|
<span class="fa fa-pencil" aria-hidden="true"></span>
|
||||||
|
Edit this Service Port
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if perms.ipam.delete_ipaddress %}
|
||||||
|
<a href="{% url 'ipam:serviceport_delete' pk=service_port.pk %}" class="btn btn-danger">
|
||||||
|
<span class="fa fa-trash" aria-hidden="true"></span>
|
||||||
|
Delete this Service Port
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<h1>{{ service_port }}</h1>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<strong>Service Port</strong>
|
||||||
|
</div>
|
||||||
|
<table class="table table-hover panel-body">
|
||||||
|
<tr>
|
||||||
|
<td>Device</td>
|
||||||
|
<td>
|
||||||
|
<span>
|
||||||
|
<a href="{% url 'dcim:device' pk=service_port.ip_address.device.pk %}">
|
||||||
|
{{ service_port.ip_address.device }}</a> ({{ service_port.ip_address.interface }})
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>IP Address</td>
|
||||||
|
<td>{{ service_port.ip_address }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>{{ service_port.name }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Description</td>
|
||||||
|
<td>
|
||||||
|
{% if service_port.description %}
|
||||||
|
<span>{{ service_port.description }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">N/A</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Created</td>
|
||||||
|
<td>{{ service_port.created }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Last Updated</td>
|
||||||
|
<td>{{ service_port.last_updated }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
40
netbox/templates/ipam/serviceport_edit.html
Normal file
40
netbox/templates/ipam/serviceport_edit.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{% extends 'utilities/obj_edit.html' %}
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
{% load form_helpers %}
|
||||||
|
|
||||||
|
{% block form %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading"><strong>Service Port</strong></div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{% render_field form.ip_address %}
|
||||||
|
{% render_field form.port %}
|
||||||
|
{% render_field form.type %}
|
||||||
|
{% render_field form.name %}
|
||||||
|
{% if obj %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-3 control-label">Device</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<p class="form-control-static">
|
||||||
|
{% if obj.ip_address.device %}
|
||||||
|
<a href="{% url 'dcim:device' pk=obj.ip_address.device.pk %}">{{ obj.ip_address.device }}</a>
|
||||||
|
{% else %}
|
||||||
|
<span>None</span>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-3 control-label">Interface</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<p class="form-control-static">{{ obj.ip_address.interface }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% render_field form.description %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
<script src="{% static 'js/livesearch.js' %}"></script>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user