Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
746eef0f
Commit
746eef0f
authored
Mar 28, 2018
by
Gabriel Detraz
Committed by
chirac
Mar 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bugs sur topologie, id et plus _id
parent
f91feff0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
47 deletions
+47
-47
topologie/models.py
topologie/models.py
+2
-2
topologie/templates/topologie/aff_constructor_switch.html
topologie/templates/topologie/aff_constructor_switch.html
+1
-1
topologie/templates/topologie/aff_model_switch.html
topologie/templates/topologie/aff_model_switch.html
+1
-1
topologie/templates/topologie/aff_port.html
topologie/templates/topologie/aff_port.html
+1
-1
topologie/urls.py
topologie/urls.py
+15
-15
topologie/views.py
topologie/views.py
+27
-27
No files found.
topologie/models.py
View file @
746eef0f
...
...
@@ -282,14 +282,14 @@ class Port(AclMixin, models.Model):
(
"view_port"
,
"Peut voir un objet port"
),
)
def
get_instance
(
port
_
id
,
*
args
,
**
kwargs
):
def
get_instance
(
portid
,
*
args
,
**
kwargs
):
return
Port
.
objects
\
.
select_related
(
'machine_interface__domain__extension'
)
\
.
select_related
(
'machine_interface__machine__switch'
)
\
.
select_related
(
'room'
)
\
.
select_related
(
'related'
)
\
.
prefetch_related
(
'switch__interface_set__domain__extension'
)
\
.
get
(
pk
=
port
_
id
)
.
get
(
pk
=
portid
)
def
make_port_related
(
self
):
""" Synchronise le port distant sur self"""
...
...
topologie/templates/topologie/aff_constructor_switch.html
View file @
746eef0f
...
...
@@ -39,7 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<td>
{{constructor_switch}}
</td>
<td
class=
"text-right"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
title=
"Historique"
href=
"{% url 'topologie:history' 'constructor
_
switch' constructor_switch.pk %}"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
title=
"Historique"
href=
"{% url 'topologie:history' 'constructorswitch' constructor_switch.pk %}"
>
<i
class=
"fa fa-history"
></i>
</a>
{% can_edit constructor_switch %}
...
...
topologie/templates/topologie/aff_model_switch.html
View file @
746eef0f
...
...
@@ -41,7 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>
{{model_switch.reference}}
</td>
<td>
{{model_switch.constructor}}
</td>
<td
class=
"text-right"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
title=
"Historique"
href=
"{% url 'topologie:history' 'model
_
switch' model_switch.pk %}"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
title=
"Historique"
href=
"{% url 'topologie:history' 'modelswitch' model_switch.pk %}"
>
<i
class=
"fa fa-history"
></i>
</a>
{% can_edit model_switch %}
...
...
topologie/templates/topologie/aff_port.html
View file @
746eef0f
...
...
@@ -52,7 +52,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</td>
<td>
{% if port.related %}
<a
href=
"{% url 'topologie:index-port' switch
_
id=port.related.switch.id %}"
>
{{ port.related }}
</a>
<a
href=
"{% url 'topologie:index-port' switchid=port.related.switch.id %}"
>
{{ port.related }}
</a>
{% endif %}
</td>
<td>
{{ port.radius }}
</td>
...
...
topologie/urls.py
View file @
746eef0f
...
...
@@ -37,18 +37,18 @@ urlpatterns = [
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^index_ap/$'
,
views
.
index_ap
,
name
=
'index-ap'
),
url
(
r
'^new_ap/$'
,
views
.
new_ap
,
name
=
'new-ap'
),
url
(
r
'^edit_ap/(?P<accesspoint
_
id>[0-9]+)$'
,
url
(
r
'^edit_ap/(?P<accesspointid>[0-9]+)$'
,
views
.
edit_ap
,
name
=
'edit-ap'
),
url
(
r
'^create_ports/(?P<switch
_
id>[0-9]+)$'
,
url
(
r
'^create_ports/(?P<switchid>[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'
),
url
(
r
'^del_room/(?P<room
_
id>[0-9]+)$'
,
views
.
del_room
,
name
=
'del-room'
),
url
(
r
'^edit_room/(?P<roomid>[0-9]+)$'
,
views
.
edit_room
,
name
=
'edit-room'
),
url
(
r
'^del_room/(?P<roomid>[0-9]+)$'
,
views
.
del_room
,
name
=
'del-room'
),
url
(
r
'^new_switch/$'
,
views
.
new_switch
,
name
=
'new-switch'
),
url
(
r
'^switch/(?P<switch
_
id>[0-9]+)$'
,
url
(
r
'^switch/(?P<switchid>[0-9]+)$'
,
views
.
index_port
,
name
=
'index-port'
),
url
(
...
...
@@ -57,18 +57,18 @@ urlpatterns = [
name
=
'history'
,
kwargs
=
{
'application'
:
'topologie'
},
),
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
'^del_port/(?P<port
_
id>[0-9]+)$'
,
views
.
del_port
,
name
=
'del-port'
),
url
(
r
'^edit_switch/(?P<switch
_
id>[0-9]+)$'
,
url
(
r
'^edit_port/(?P<portid>[0-9]+)$'
,
views
.
edit_port
,
name
=
'edit-port'
),
url
(
r
'^new_port/(?P<switchid>[0-9]+)$'
,
views
.
new_port
,
name
=
'new-port'
),
url
(
r
'^del_port/(?P<portid>[0-9]+)$'
,
views
.
del_port
,
name
=
'del-port'
),
url
(
r
'^edit_switch/(?P<switchid>[0-9]+)$'
,
views
.
edit_switch
,
name
=
'edit-switch'
),
url
(
r
'^new_stack/$'
,
views
.
new_stack
,
name
=
'new-stack'
),
url
(
r
'^index_stack/$'
,
views
.
index_stack
,
name
=
'index-stack'
),
url
(
r
'^edit_stack/(?P<stack
_
id>[0-9]+)$'
,
url
(
r
'^edit_stack/(?P<stackid>[0-9]+)$'
,
views
.
edit_stack
,
name
=
'edit-stack'
),
url
(
r
'^del_stack/(?P<stack
_
id>[0-9]+)$'
,
url
(
r
'^del_stack/(?P<stackid>[0-9]+)$'
,
views
.
del_stack
,
name
=
'del-stack'
),
url
(
r
'^index_model_switch/$'
,
...
...
@@ -83,20 +83,20 @@ urlpatterns = [
views
.
new_model_switch
,
name
=
'new-model-switch'
),
url
(
r
'^edit_model_switch/(?P<model
_switch_
id>[0-9]+)$'
,
url
(
r
'^edit_model_switch/(?P<model
switch
id>[0-9]+)$'
,
views
.
edit_model_switch
,
name
=
'edit-model-switch'
),
url
(
r
'^del_model_switch/(?P<model
_switch_
id>[0-9]+)$'
,
url
(
r
'^del_model_switch/(?P<model
switch
id>[0-9]+)$'
,
views
.
del_model_switch
,
name
=
'del-model-switch'
),
url
(
r
'^new_constructor_switch/$'
,
views
.
new_constructor_switch
,
name
=
'new-constructor-switch'
),
url
(
r
'^edit_constructor_switch/(?P<constructor
_switch_
id>[0-9]+)$'
,
url
(
r
'^edit_constructor_switch/(?P<constructor
switch
id>[0-9]+)$'
,
views
.
edit_constructor_switch
,
name
=
'edit-constructor-switch'
),
url
(
r
'^del_constructor_switch/(?P<constructor
_switch_
id>[0-9]+)$'
,
url
(
r
'^del_constructor_switch/(?P<constructor
switch
id>[0-9]+)$'
,
views
.
del_constructor_switch
,
name
=
'del-constructor-switch'
),
]
topologie/views.py
View file @
746eef0f
...
...
@@ -123,7 +123,7 @@ def index(request):
@
login_required
@
can_view_all
(
Port
)
@
can_view
(
Switch
)
def
index_port
(
request
,
switch
,
switch
_
id
):
def
index_port
(
request
,
switch
,
switchid
):
""" Affichage de l'ensemble des ports reliés à un switch particulier"""
port_list
=
Port
.
objects
.
filter
(
switch
=
switch
)
\
.
select_related
(
'room'
)
\
...
...
@@ -143,7 +143,7 @@ def index_port(request, switch, switch_id):
)
return
render
(
request
,
'topologie/index_p.html'
,
{
'port_list'
:
port_list
,
'id_switch'
:
switch
_
id
,
'id_switch'
:
switchid
,
'nom_switch'
:
switch
})
...
...
@@ -250,10 +250,10 @@ def index_model_switch(request):
@
login_required
@
can_create
(
Port
)
def
new_port
(
request
,
switch
_
id
):
def
new_port
(
request
,
switchid
):
""" Nouveau port"""
try
:
switch
=
Switch
.
objects
.
get
(
pk
=
switch
_
id
)
switch
=
Switch
.
objects
.
get
(
pk
=
switchid
)
except
Switch
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Switch inexistant"
)
return
redirect
(
reverse
(
'topologie:index'
))
...
...
@@ -271,14 +271,14 @@ def new_port(request, switch_id):
messages
.
error
(
request
,
"Ce port existe déjà"
)
return
redirect
(
reverse
(
'topologie:index-port'
,
kwargs
=
{
'switch
_id'
:
switch_
id
}
kwargs
=
{
'switch
id'
:
switch
id
}
))
return
form
({
'id_switch'
:
switch
_
id
,
'topoform'
:
port
,
'action_name'
:
'Ajouter'
},
'topologie/topo.html'
,
request
)
return
form
({
'id_switch'
:
switchid
,
'topoform'
:
port
,
'action_name'
:
'Ajouter'
},
'topologie/topo.html'
,
request
)
@
login_required
@
can_edit
(
Port
)
def
edit_port
(
request
,
port_object
,
port
_
id
):
def
edit_port
(
request
,
port_object
,
portid
):
""" Edition d'un port. Permet de changer le switch parent et
l'affectation du port"""
...
...
@@ -293,14 +293,14 @@ def edit_port(request, port_object, port_id):
messages
.
success
(
request
,
"Le port a bien été modifié"
)
return
redirect
(
reverse
(
'topologie:index-port'
,
kwargs
=
{
'switch
_
id'
:
str
(
port_object
.
switch
.
id
)}
kwargs
=
{
'switchid'
:
str
(
port_object
.
switch
.
id
)}
))
return
form
({
'id_switch'
:
str
(
port_object
.
switch
.
id
),
'topoform'
:
port
,
'action_name'
:
'Editer'
},
'topologie/topo.html'
,
request
)
@
login_required
@
can_delete
(
Port
)
def
del_port
(
request
,
port
,
port
_
id
):
def
del_port
(
request
,
port
,
portid
):
""" Supprime le port"""
if
request
.
method
==
"POST"
:
try
:
...
...
@@ -314,7 +314,7 @@ def del_port(request, port, port_id):
impossible de le supprimer"
%
port
)
return
redirect
(
reverse
(
'topologie:index-port'
,
kwargs
=
{
'switch
_
id'
:
str
(
port
.
switch
.
id
)}
kwargs
=
{
'switchid'
:
str
(
port
.
switch
.
id
)}
))
return
form
({
'objet'
:
port
},
'topologie/delete.html'
,
request
)
...
...
@@ -322,7 +322,7 @@ def del_port(request, port, port_id):
@
login_required
@
can_create
(
Stack
)
def
new_stack
(
request
):
"""Ajoute un nouveau stack : stack
_
id_min, max, et nombre de switches"""
"""Ajoute un nouveau stack : stackid_min, max, et nombre de switches"""
stack
=
StackForm
(
request
.
POST
or
None
)
if
stack
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
...
...
@@ -335,7 +335,7 @@ def new_stack(request):
@
login_required
@
can_edit
(
Stack
)
def
edit_stack
(
request
,
stack
,
stack
_
id
):
def
edit_stack
(
request
,
stack
,
stackid
):
"""Edition d'un stack (nombre de switches, nom...)"""
stack
=
StackForm
(
request
.
POST
or
None
,
instance
=
stack
)
...
...
@@ -354,7 +354,7 @@ def edit_stack(request, stack, stack_id):
@
login_required
@
can_delete
(
Stack
)
def
del_stack
(
request
,
stack
,
stack
_
id
):
def
del_stack
(
request
,
stack
,
stackid
):
"""Supprime un stack"""
if
request
.
method
==
"POST"
:
try
:
...
...
@@ -372,7 +372,7 @@ def del_stack(request, stack, stack_id):
@
login_required
@
can_edit
(
Stack
)
def
edit_switchs_stack
(
request
,
stack
,
stack
_
id
):
def
edit_switchs_stack
(
request
,
stack
,
stackid
):
"""Permet d'éditer la liste des switches dans une stack et l'ajouter"""
if
request
.
method
==
"POST"
:
...
...
@@ -440,10 +440,10 @@ def new_switch(request):
@
login_required
@
can_create
(
Port
)
def
create_ports
(
request
,
switch
_
id
):
def
create_ports
(
request
,
switchid
):
""" Création d'une liste de ports pour un switch."""
try
:
switch
=
Switch
.
objects
.
get
(
pk
=
switch
_
id
)
switch
=
Switch
.
objects
.
get
(
pk
=
switchid
)
except
Switch
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Switch inexistant"
)
return
redirect
(
reverse
(
'topologie:index'
))
...
...
@@ -471,14 +471,14 @@ def create_ports(request, switch_id):
return
redirect
(
reverse
(
'topologie:index-port'
,
kwargs
=
{
'switch
_id'
:
switch_
id
}
kwargs
=
{
'switch
id'
:
switch
id
}
))
return
form
({
'id_switch'
:
switch
_
id
,
'topoform'
:
port_form
},
'topologie/switch.html'
,
request
)
return
form
({
'id_switch'
:
switchid
,
'topoform'
:
port_form
},
'topologie/switch.html'
,
request
)
@
login_required
@
can_edit
(
Switch
)
def
edit_switch
(
request
,
switch
,
switch
_
id
):
def
edit_switch
(
request
,
switch
,
switchid
):
""" Edition d'un switch. Permet de chambre nombre de ports,
place dans le stack, interface et machine associée"""
...
...
@@ -524,7 +524,7 @@ def edit_switch(request, switch, switch_id):
return
redirect
(
reverse
(
'topologie:index'
))
i_mbf_param
=
generate_ipv4_mbf_param
(
interface_form
,
False
)
return
form
({
'id_switch'
:
switch
_
id
,
'id_switch'
:
switchid
,
'topoform'
:
interface_form
,
'machineform'
:
switch_form
,
'domainform'
:
domain_form
,
...
...
@@ -590,7 +590,7 @@ def new_ap(request):
@
login_required
@
can_edit
(
AccessPoint
)
def
edit_ap
(
request
,
ap
,
a
p_
id
):
def
edit_ap
(
request
,
ap
,
a
ccesspoint
id
):
""" Edition d'un switch. Permet de chambre nombre de ports,
place dans le stack, interface et machine associée"""
interface_form
=
EditInterfaceForm
(
...
...
@@ -665,7 +665,7 @@ def new_room(request):
@
login_required
@
can_edit
(
Room
)
def
edit_room
(
request
,
room
,
room
_
id
):
def
edit_room
(
request
,
room
,
roomid
):
""" Edition numero et details de la chambre"""
room
=
EditRoomForm
(
request
.
POST
or
None
,
instance
=
room
)
...
...
@@ -683,7 +683,7 @@ def edit_room(request, room, room_id):
@
login_required
@
can_delete
(
Room
)
def
del_room
(
request
,
room
,
room
_
id
):
def
del_room
(
request
,
room
,
roomid
):
""" Suppression d'un chambre"""
if
request
.
method
==
"POST"
:
try
:
...
...
@@ -719,7 +719,7 @@ def new_model_switch(request):
@
login_required
@
can_edit
(
ModelSwitch
)
def
edit_model_switch
(
request
,
model_switch
,
model
_switch_
id
):
def
edit_model_switch
(
request
,
model_switch
,
model
switch
id
):
""" Edition d'un modèle de switch"""
model_switch
=
EditModelSwitchForm
(
request
.
POST
or
None
,
instance
=
model_switch
)
...
...
@@ -737,7 +737,7 @@ def edit_model_switch(request, model_switch, model_switch_id):
@
login_required
@
can_delete
(
ModelSwitch
)
def
del_model_switch
(
request
,
model_switch
_
id
):
def
del_model_switch
(
request
,
model_switch
,
modelswitch
id
):
""" Suppression d'un modèle de switch"""
if
request
.
method
==
"POST"
:
try
:
...
...
@@ -773,7 +773,7 @@ def new_constructor_switch(request):
@
login_required
@
can_edit
(
ConstructorSwitch
)
def
edit_constructor_switch
(
request
,
constructor_switch
,
constructor
_switch_
id
):
def
edit_constructor_switch
(
request
,
constructor_switch
,
constructor
switch
id
):
""" Edition d'un constructeur de switch"""
constructor_switch
=
EditConstructorSwitchForm
(
request
.
POST
or
None
,
instance
=
constructor_switch
)
...
...
@@ -791,7 +791,7 @@ def edit_constructor_switch(request, constructor_switch, constructor_switch_id):
@
login_required
@
can_delete
(
ConstructorSwitch
)
def
del_constructor_switch
(
request
,
constructor_switch
_
id
):
def
del_constructor_switch
(
request
,
constructor_switch
,
constructorswitch
id
):
""" Suppression d'un constructeur de switch"""
if
request
.
method
==
"POST"
:
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment