mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Suppression des ports
This commit is contained in:
parent
9a4b7962ec
commit
00c72ade80
3 changed files with 24 additions and 0 deletions
|
@ -62,6 +62,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-port' port.id %}">
|
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-port' port.id %}">
|
||||||
<i class="glyphicon glyphicon-edit"></i>
|
<i class="glyphicon glyphicon-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-port' port.pk %}">
|
||||||
|
<i class="glyphicon glyphicon-trash"></i>
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -38,6 +38,7 @@ urlpatterns = [
|
||||||
url(r'^history/(?P<object>stack)/(?P<id>[0-9]+)$', views.history, name='history'),
|
url(r'^history/(?P<object>stack)/(?P<id>[0-9]+)$', views.history, name='history'),
|
||||||
url(r'^edit_port/(?P<port_id>[0-9]+)$', views.edit_port, name='edit-port'),
|
url(r'^edit_port/(?P<port_id>[0-9]+)$', views.edit_port, name='edit-port'),
|
||||||
url(r'^new_port/(?P<switch_id>[0-9]+)$', views.new_port, name='new-port'),
|
url(r'^new_port/(?P<switch_id>[0-9]+)$', views.new_port, name='new-port'),
|
||||||
|
url(r'^del_port/(?P<port_id>[0-9]+)$', views.del_port, name='del-port'),
|
||||||
url(r'^edit_switch/(?P<switch_id>[0-9]+)$', views.edit_switch, name='edit-switch'),
|
url(r'^edit_switch/(?P<switch_id>[0-9]+)$', views.edit_switch, name='edit-switch'),
|
||||||
url(r'^new_stack/$', views.new_stack, name='new-stack'),
|
url(r'^new_stack/$', views.new_stack, name='new-stack'),
|
||||||
url(r'^index_stack/$', views.index_stack, name='index-stack'),
|
url(r'^index_stack/$', views.index_stack, name='index-stack'),
|
||||||
|
|
|
@ -167,6 +167,26 @@ def edit_port(request, port_id):
|
||||||
return redirect("/topologie/switch/" + str(port_object.switch.id))
|
return redirect("/topologie/switch/" + str(port_object.switch.id))
|
||||||
return form({'topoform':port}, 'topologie/topo.html', request)
|
return form({'topoform':port}, 'topologie/topo.html', request)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@permission_required('infra')
|
||||||
|
def del_port(request,port_id):
|
||||||
|
try:
|
||||||
|
port = Port.objects.get(pk=port_id)
|
||||||
|
except Port.DoesNotExist:
|
||||||
|
messages.error(request, u"Port inexistant")
|
||||||
|
return redirect('/topologie/')
|
||||||
|
if request.method == "POST":
|
||||||
|
try:
|
||||||
|
with transaction.atomic(), reversion.create_revision():
|
||||||
|
port.delete()
|
||||||
|
reversion.set_user(request.user)
|
||||||
|
reversion.set_comment("Destruction")
|
||||||
|
messages.success(request, "Le port a eté détruit")
|
||||||
|
except ProtectedError:
|
||||||
|
messages.error(request, "Le port %s est affecté à un autre objet, impossible de le supprimer" % port)
|
||||||
|
return redirect('/topologie/switch/' + str(port.switch.id))
|
||||||
|
return form({'objet':port}, 'topologie/delete.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('infra')
|
@permission_required('infra')
|
||||||
def new_stack(request):
|
def new_stack(request):
|
||||||
|
|
Loading…
Reference in a new issue