mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Merge branch 'klafyvel' of https://gitlab.rezometz.org/rezo/re2o into klafyvel
This commit is contained in:
commit
fddeaa2ef2
2 changed files with 19 additions and 16 deletions
|
@ -35,7 +35,9 @@ from . import views
|
|||
urlpatterns = [
|
||||
url(r'^$', views.index, name='index'),
|
||||
url(r'^new_switch/$', views.new_switch, name='new-switch'),
|
||||
url(r'^create_ports/(?P<switch_id>[0-9]+)$', views.create_ports, name='create-ports'),
|
||||
url(r'^create_ports/(?P<switch_id>[0-9]+)$',
|
||||
views.create_ports,
|
||||
name='create-ports'),
|
||||
url(r'^index_room/$', views.index_room, name='index-room'),
|
||||
url(r'^new_room/$', views.new_room, name='new-room'),
|
||||
url(r'^edit_room/(?P<room_id>[0-9]+)$', views.edit_room, name='edit-room'),
|
||||
|
|
|
@ -184,7 +184,9 @@ def index_port(request, switch_id):
|
|||
.select_related('room')\
|
||||
.select_related('machine_interface__domain__extension')\
|
||||
.select_related('machine_interface__machine__user')\
|
||||
.select_related('related__switch__switch_interface__domain__extension')\
|
||||
.select_related(
|
||||
'related__switch__switch_interface__domain__extension'
|
||||
)\
|
||||
.select_related('switch')
|
||||
port_list = SortTable.sort(
|
||||
port_list,
|
||||
|
@ -470,7 +472,7 @@ def new_switch(request):
|
|||
reversion.set_comment("Création")
|
||||
messages.success(request, "Le switch a été créé")
|
||||
return redirect("/topologie/")
|
||||
i_mbf_param = generate_ipv4_mbf_param( interface, False )
|
||||
i_mbf_param = generate_ipv4_mbf_param(interface, False)
|
||||
return form({
|
||||
'topoform': switch,
|
||||
'machineform': machine,
|
||||
|
@ -479,6 +481,7 @@ def new_switch(request):
|
|||
'i_mbf_param': i_mbf_param
|
||||
}, 'topologie/switch.html', request)
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('infra')
|
||||
def create_ports(request, switch_id):
|
||||
|
@ -498,13 +501,11 @@ def create_ports(request, switch_id):
|
|||
|
||||
port_form = CreatePortsForm(
|
||||
request.POST or None,
|
||||
initial={'begin':s_begin,'end':s_end}
|
||||
initial={'begin': s_begin, 'end': s_end}
|
||||
)
|
||||
if port_form.is_valid():
|
||||
begin = port_form.cleaned_data['begin']
|
||||
end = port_form.cleaned_data['end']
|
||||
b = []
|
||||
e = []
|
||||
if end < begin:
|
||||
messages.error(request, "Port de fin inférieur au port de début !")
|
||||
return redirect("/topologie/switch/" + str(switch.id))
|
||||
|
@ -512,15 +513,15 @@ def create_ports(request, switch_id):
|
|||
messages.error(request, "Ce switch ne peut avoir autant de ports.")
|
||||
return redirect("/topologie/switch/" + str(switch.id))
|
||||
|
||||
b = range(begin, s_begin)
|
||||
e = range(s_end+1, end+1)
|
||||
for i in itertools.chain(b,e):
|
||||
p = Port()
|
||||
p.switch = switch
|
||||
p.port = i
|
||||
begin_range = range(begin, s_begin)
|
||||
end_range = range(s_end+1, end+1)
|
||||
for i in itertools.chain(begin_range, end_range):
|
||||
port = Port()
|
||||
port.switch = switch
|
||||
port.port = i
|
||||
try:
|
||||
with transaction.atomic(), reversion.create_revision():
|
||||
p.save()
|
||||
port.save()
|
||||
reversion.set_user(request.user)
|
||||
reversion.set_comment("Création")
|
||||
messages.success(request, "Création du port %d" % i)
|
||||
|
@ -528,8 +529,8 @@ def create_ports(request, switch_id):
|
|||
messages.error(request, "Création d'un port existant.")
|
||||
return redirect("/topologie/switch/" + str(switch.id))
|
||||
|
||||
return form({'topoform': port_form,}, 'topologie/switch.html', request)
|
||||
|
||||
return form({'topoform': port_form}, 'topologie/switch.html', request)
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('infra')
|
||||
|
@ -588,7 +589,7 @@ def edit_switch(request, switch_id):
|
|||
)
|
||||
messages.success(request, "Le switch a bien été modifié")
|
||||
return redirect("/topologie/")
|
||||
i_mbf_param = generate_ipv4_mbf_param( interface_form, False )
|
||||
i_mbf_param = generate_ipv4_mbf_param(interface_form, False)
|
||||
return form({
|
||||
'topoform': switch_form,
|
||||
'machineform': machine_form,
|
||||
|
|
Loading…
Reference in a new issue