Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Re2o
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levy--Falk Hugo
Re2o
Commits
297e300a
Commit
297e300a
authored
Mar 26, 2018
by
Gabriel Detraz
Committed by
chirac
Mar 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Borne en AccessPoint
parent
50d04b0a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
174 additions
and
71 deletions
+174
-71
acl.py
re2o/templatetags/acl.py
+1
-0
utils.py
re2o/utils.py
+3
-3
views.py
re2o/views.py
+1
-1
admin.py
topologie/admin.py
+3
-3
forms.py
topologie/forms.py
+5
-5
0044_auto_20180326_0002.py
topologie/migrations/0044_auto_20180326_0002.py
+28
-0
models.py
topologie/models.py
+9
-9
aff_ap.html
topologie/templates/topologie/aff_ap.html
+74
-0
index_ap.html
topologie/templates/topologie/index_ap.html
+3
-3
sidebar.html
topologie/templates/topologie/sidebar.html
+1
-1
urls.py
topologie/urls.py
+5
-5
views.py
topologie/views.py
+41
-41
No files found.
re2o/templatetags/acl.py
View file @
297e300a
...
@@ -122,6 +122,7 @@ MODEL_NAME = {
...
@@ -122,6 +122,7 @@ MODEL_NAME = {
# topologie
# topologie
'Stack'
:
topologie
.
models
.
Stack
,
'Stack'
:
topologie
.
models
.
Stack
,
'Switch'
:
topologie
.
models
.
Switch
,
'Switch'
:
topologie
.
models
.
Switch
,
'AccessPoint'
:
topologie
.
models
.
AccessPoint
,
'ModelSwitch'
:
topologie
.
models
.
ModelSwitch
,
'ModelSwitch'
:
topologie
.
models
.
ModelSwitch
,
'ConstructorSwitch'
:
topologie
.
models
.
ConstructorSwitch
,
'ConstructorSwitch'
:
topologie
.
models
.
ConstructorSwitch
,
'Port'
:
topologie
.
models
.
Port
,
'Port'
:
topologie
.
models
.
Port
,
...
...
re2o/utils.py
View file @
297e300a
...
@@ -234,9 +234,9 @@ class SortTable:
...
@@ -234,9 +234,9 @@ class SortTable:
'default'
:
[
'name'
]
'default'
:
[
'name'
]
}
}
TOPOLOGIE_INDEX_BORNE
=
{
TOPOLOGIE_INDEX_BORNE
=
{
'
borne
_name'
:
[
'domain__name'
],
'
ap
_name'
:
[
'domain__name'
],
'
borne
_ip'
:
[
'ipv4__ipv4'
],
'
ap
_ip'
:
[
'ipv4__ipv4'
],
'
borne
_mac'
:
[
'mac_address'
],
'
ap
_mac'
:
[
'mac_address'
],
'default'
:
[
'domain__name'
]
'default'
:
[
'domain__name'
]
}
}
TOPOLOGIE_INDEX_STACK
=
{
TOPOLOGIE_INDEX_STACK
=
{
...
...
re2o/views.py
View file @
297e300a
...
@@ -83,7 +83,7 @@ HISTORY_BIND = {
...
@@ -83,7 +83,7 @@ HISTORY_BIND = {
'stack'
:
topologie
.
models
.
Stack
,
'stack'
:
topologie
.
models
.
Stack
,
'model_switch'
:
topologie
.
models
.
ModelSwitch
,
'model_switch'
:
topologie
.
models
.
ModelSwitch
,
'constructor_switch'
:
topologie
.
models
.
ConstructorSwitch
,
'constructor_switch'
:
topologie
.
models
.
ConstructorSwitch
,
'
borne'
:
topologie
.
models
.
Borne
,
'
ap'
:
topologie
.
models
.
AccessPoint
,
},
},
'machines'
:
{
'machines'
:
{
'machine'
:
machines
.
models
.
Machine
,
'machine'
:
machines
.
models
.
Machine
,
...
...
topologie/admin.py
View file @
297e300a
...
@@ -36,7 +36,7 @@ from .models import (
...
@@ -36,7 +36,7 @@ from .models import (
Stack
,
Stack
,
ModelSwitch
,
ModelSwitch
,
ConstructorSwitch
,
ConstructorSwitch
,
Borne
AccessPoint
)
)
...
@@ -55,7 +55,7 @@ class PortAdmin(VersionAdmin):
...
@@ -55,7 +55,7 @@ class PortAdmin(VersionAdmin):
pass
pass
class
Borne
Admin
(
VersionAdmin
):
class
AccessPoint
Admin
(
VersionAdmin
):
"""Administration d'une borne"""
"""Administration d'une borne"""
pass
pass
...
@@ -76,7 +76,7 @@ class ConstructorSwitchAdmin(VersionAdmin):
...
@@ -76,7 +76,7 @@ class ConstructorSwitchAdmin(VersionAdmin):
admin
.
site
.
register
(
Port
,
PortAdmin
)
admin
.
site
.
register
(
Port
,
PortAdmin
)
admin
.
site
.
register
(
Borne
,
Borne
Admin
)
admin
.
site
.
register
(
AccessPoint
,
AccessPoint
Admin
)
admin
.
site
.
register
(
Room
,
RoomAdmin
)
admin
.
site
.
register
(
Room
,
RoomAdmin
)
admin
.
site
.
register
(
Switch
,
SwitchAdmin
)
admin
.
site
.
register
(
Switch
,
SwitchAdmin
)
admin
.
site
.
register
(
Stack
,
StackAdmin
)
admin
.
site
.
register
(
Stack
,
StackAdmin
)
...
...
topologie/forms.py
View file @
297e300a
...
@@ -43,7 +43,7 @@ from .models import (
...
@@ -43,7 +43,7 @@ from .models import (
Stack
,
Stack
,
ModelSwitch
,
ModelSwitch
,
ConstructorSwitch
,
ConstructorSwitch
,
Borne
AccessPoint
)
)
...
@@ -111,18 +111,18 @@ class StackForm(ModelForm):
...
@@ -111,18 +111,18 @@ class StackForm(ModelForm):
super
(
StackForm
,
self
)
.
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
super
(
StackForm
,
self
)
.
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
class
Add
Borne
Form
(
EditInterfaceForm
):
class
Add
AccessPoint
Form
(
EditInterfaceForm
):
"""Formulaire pour la création d'une borne
"""Formulaire pour la création d'une borne
Relié directement au modèle borne"""
Relié directement au modèle borne"""
class
Meta
:
class
Meta
:
model
=
Borne
model
=
AccessPoint
fields
=
[
'mac_address'
,
'type'
,
'ipv4'
,
'details'
,
'location'
]
fields
=
[
'mac_address'
,
'type'
,
'ipv4'
,
'details'
,
'location'
]
class
Edit
Borne
Form
(
EditInterfaceForm
):
class
Edit
AccessPoint
Form
(
EditInterfaceForm
):
"""Edition d'une interface. Edition complète"""
"""Edition d'une interface. Edition complète"""
class
Meta
:
class
Meta
:
model
=
Borne
model
=
AccessPoint
fields
=
[
'machine'
,
'type'
,
'ipv4'
,
'mac_address'
,
'details'
,
'location'
]
fields
=
[
'machine'
,
'type'
,
'ipv4'
,
'mac_address'
,
'details'
,
'location'
]
...
...
topologie/migrations/0044_auto_20180326_0002.py
0 → 100644
View file @
297e300a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-03-25 22:02
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'topologie'
,
'0043_renamenewswitch'
),
]
operations
=
[
migrations
.
RenameModel
(
old_name
=
'Borne'
,
new_name
=
'AccessPoint'
,
),
migrations
.
AlterModelOptions
(
name
=
'accesspoint'
,
options
=
{
'permissions'
:
((
'view_ap'
,
'Peut voir une borne'
),)},
),
migrations
.
AlterModelOptions
(
name
=
'switch'
,
options
=
{
'permissions'
:
((
'view_switch'
,
'Peut voir un objet switch'
),)},
),
]
topologie/models.py
View file @
297e300a
...
@@ -109,7 +109,7 @@ class Stack(models.Model):
...
@@ -109,7 +109,7 @@ class Stack(models.Model):
inférieure à l'id minimale"
})
inférieure à l'id minimale"
})
class
Borne
(
Interface
):
class
AccessPoint
(
Interface
):
"""Define a wireless AP. Inherit from machines.interfaces
"""Define a wireless AP. Inherit from machines.interfaces
Definition pour une borne wifi , hérite de machines.interfaces
Definition pour une borne wifi , hérite de machines.interfaces
...
@@ -125,33 +125,33 @@ class Borne(Interface):
...
@@ -125,33 +125,33 @@ class Borne(Interface):
class
Meta
:
class
Meta
:
permissions
=
(
permissions
=
(
(
"view_
borne
"
,
"Peut voir une borne"
),
(
"view_
ap
"
,
"Peut voir une borne"
),
)
)
def
get_instance
(
borne
_id
,
*
args
,
**
kwargs
):
def
get_instance
(
ap
_id
,
*
args
,
**
kwargs
):
return
Borne
.
objects
.
get
(
pk
=
borne
_id
)
return
AccessPoint
.
objects
.
get
(
pk
=
ap
_id
)
def
can_create
(
user_request
,
*
args
,
**
kwargs
):
def
can_create
(
user_request
,
*
args
,
**
kwargs
):
return
user_request
.
has_perm
(
'topologie.add_
borne
'
)
,
u"Vous n'avez pas le droit
\
return
user_request
.
has_perm
(
'topologie.add_
ap
'
)
,
u"Vous n'avez pas le droit
\
de créer une borne"
de créer une borne"
def
can_edit
(
self
,
user_request
,
*
args
,
**
kwargs
):
def
can_edit
(
self
,
user_request
,
*
args
,
**
kwargs
):
if
not
user_request
.
has_perm
(
'topologie.change_
borne
'
):
if
not
user_request
.
has_perm
(
'topologie.change_
ap
'
):
return
False
,
u"Vous n'avez pas le droit d'éditer des bornes"
return
False
,
u"Vous n'avez pas le droit d'éditer des bornes"
return
True
,
None
return
True
,
None
def
can_delete
(
self
,
user_request
,
*
args
,
**
kwargs
):
def
can_delete
(
self
,
user_request
,
*
args
,
**
kwargs
):
if
not
user_request
.
has_perm
(
'topologie.delete_
borne
'
):
if
not
user_request
.
has_perm
(
'topologie.delete_
ap
'
):
return
False
,
u"Vous n'avez pas le droit de supprimer une borne"
return
False
,
u"Vous n'avez pas le droit de supprimer une borne"
return
True
,
None
return
True
,
None
def
can_view_all
(
user_request
,
*
args
,
**
kwargs
):
def
can_view_all
(
user_request
,
*
args
,
**
kwargs
):
if
not
user_request
.
has_perm
(
'topologie.view_
borne
'
):
if
not
user_request
.
has_perm
(
'topologie.view_
ap
'
):
return
False
,
u"Vous n'avez pas le droit de voir les bornes"
return
False
,
u"Vous n'avez pas le droit de voir les bornes"
return
True
,
None
return
True
,
None
def
can_view
(
self
,
user_request
,
*
args
,
**
kwargs
):
def
can_view
(
self
,
user_request
,
*
args
,
**
kwargs
):
if
not
user_request
.
has_perm
(
'topologie.view_
borne
'
):
if
not
user_request
.
has_perm
(
'topologie.view_
ap
'
):
return
False
,
u"Vous n'avez pas le droit de voir les bornes"
return
False
,
u"Vous n'avez pas le droit de voir les bornes"
return
True
,
None
return
True
,
None
...
...
topologie/templates/topologie/aff_
borne
.html
→
topologie/templates/topologie/aff_
ap
.html
View file @
297e300a
...
@@ -25,50 +25,50 @@ with this program; if not, write to the Free Software Foundation, Inc.,
...
@@ -25,50 +25,50 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load acl %}
{% load acl %}
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% if borne
_list.paginator %}
{% if ap
_list.paginator %}
{% include "pagination.html" with list=borne
_list %}
{% include "pagination.html" with list=ap
_list %}
{% endif %}
{% endif %}
<table
class=
"table table-striped"
>
<table
class=
"table table-striped"
>
<thead>
<thead>
<tr>
<tr>
<th>
{% include "buttons/sort.html" with prefix='borne
' col='name' text='Borne' %}
</th>
<th>
{% include "buttons/sort.html" with prefix='ap
' col='name' text='Borne' %}
</th>
<th>
{% include "buttons/sort.html" with prefix='borne
' col='mac' text='Addresse mac' %}
</th>
<th>
{% include "buttons/sort.html" with prefix='ap
' col='mac' text='Addresse mac' %}
</th>
<th>
{% include "buttons/sort.html" with prefix='borne
' col='ip' text='Ipv4' %}
</th>
<th>
{% include "buttons/sort.html" with prefix='ap
' col='ip' text='Ipv4' %}
</th>
<th>
Commentaire
</th>
<th>
Commentaire
</th>
<th>
Localisation
</th>
<th>
Localisation
</th>
<th></th>
<th></th>
</tr>
</tr>
</thead>
</thead>
{% for borne in borne
_list %}
{% for ap in ap
_list %}
<tr>
<tr>
<td>
{{borne
}}
</td>
<td>
{{ap
}}
</td>
<td>
{{borne
.mac_address}}
</td>
<td>
{{ap
.mac_address}}
</td>
<td>
{{borne
.ipv4}}
</td>
<td>
{{ap
.ipv4}}
</td>
<td>
{{borne
.details}}
</td>
<td>
{{ap
.details}}
</td>
<td>
{{borne
.location}}
</td>
<td>
{{ap
.location}}
</td>
<td
class=
"text-right"
>
<td
class=
"text-right"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
title=
"Historique"
href=
"{% url 'topologie:history' 'borne' borne
.pk %}"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
title=
"Historique"
href=
"{% url 'topologie:history' 'ap' ap
.pk %}"
>
<i
class=
"fa fa-history"
></i>
<i
class=
"fa fa-history"
></i>
</a>
</a>
{% can_edit borne
%}
{% can_edit ap
%}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
title=
"Éditer"
href=
"{% url 'topologie:edit-borne' borne
.id %}"
>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
title=
"Éditer"
href=
"{% url 'topologie:edit-ap' ap
.id %}"
>
<i
class=
"fa fa-edit"
></i>
<i
class=
"fa fa-edit"
></i>
</a>
</a>
{% acl_end %}
{% acl_end %}
{% can_delete borne
%}
{% can_delete ap
%}
<a
class=
"btn btn-danger btn-sm"
role=
"button"
title=
"Supprimer"
href=
"{% url 'machines:del-interface' borne
.id %}"
>
<a
class=
"btn btn-danger btn-sm"
role=
"button"
title=
"Supprimer"
href=
"{% url 'machines:del-interface' ap
.id %}"
>
<i
class=
"fa fa-trash"
></i>
<i
class=
"fa fa-trash"
></i>
</a>
</a>
{% acl_end %}
{% acl_end %}
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</table>
</table>
{% if borne
_list.paginator %}
{% if ap
_list.paginator %}
{% include "pagination.html" with list=
borne
_list %}
{% include "pagination.html" with list=
ap
_list %}
{% endif %}
{% endif %}
</div>
</div>
topologie/templates/topologie/index_
borne
.html
→
topologie/templates/topologie/index_
ap
.html
View file @
297e300a
...
@@ -30,11 +30,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
...
@@ -30,11 +30,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block content %}
{% block content %}
<h2>
Points d'accès WiFi
</h2>
<h2>
Points d'accès WiFi
</h2>
{% can_create
Room
%}
{% can_create
AccessPoint
%}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'topologie:new-
borne
' %}"
><i
class=
"fa fa-plus"
></i>
Ajouter une borne
</a>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'topologie:new-
ap
' %}"
><i
class=
"fa fa-plus"
></i>
Ajouter une borne
</a>
<hr>
<hr>
{% acl_end %}
{% acl_end %}
{% include "topologie/aff_
borne.html" with borne_list=borne
_list %}
{% include "topologie/aff_
ap.html" with ap_list=ap
_list %}
<br
/>
<br
/>
<br
/>
<br
/>
<br
/>
<br
/>
...
...
topologie/templates/topologie/sidebar.html
View file @
297e300a
...
@@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
...
@@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i
class=
"fa fa-microchip"
></i>
<i
class=
"fa fa-microchip"
></i>
Switchs
Switchs
</a>
</a>
<a
class=
"list-group-item list-group-item-info"
href=
"{% url "
topologie:index-
borne
"
%}"
>
<a
class=
"list-group-item list-group-item-info"
href=
"{% url "
topologie:index-
ap
"
%}"
>
<i
class=
"fa fa-wifi"
></i>
<i
class=
"fa fa-wifi"
></i>
Bornes WiFi
Bornes WiFi
</a>
</a>
...
...
topologie/urls.py
View file @
297e300a
...
@@ -35,11 +35,11 @@ from . import views
...
@@ -35,11 +35,11 @@ from . import views
urlpatterns
=
[
urlpatterns
=
[
url
(
r'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r'^index_
borne/$'
,
views
.
index_borne
,
name
=
'index-borne
'
),
url
(
r'^index_
ap/$'
,
views
.
index_ap
,
name
=
'index-ap
'
),
url
(
r'^new_
borne/$'
,
views
.
new_borne
,
name
=
'new-borne
'
),
url
(
r'^new_
ap/$'
,
views
.
new_ap
,
name
=
'new-ap
'
),
url
(
r'^edit_
borne/(?P<borne
_id>[0-9]+)$'
,
url
(
r'^edit_
ap/(?P<ap
_id>[0-9]+)$'
,
views
.
edit_
borne
,
views
.
edit_
ap
,
name
=
'edit-
borne
'
),
name
=
'edit-
ap
'
),
url
(
r'^create_ports/(?P<switch_id>[0-9]+)$'
,
url
(
r'^create_ports/(?P<switch_id>[0-9]+)$'
,
views
.
create_ports
,
views
.
create_ports
,
name
=
'create-ports'
),
name
=
'create-ports'
),
...
...
topologie/views.py
View file @
297e300a
...
@@ -54,7 +54,7 @@ from topologie.models import (
...
@@ -54,7 +54,7 @@ from topologie.models import (
Stack
,
Stack
,
ModelSwitch
,
ModelSwitch
,
ConstructorSwitch
,
ConstructorSwitch
,
Borne
AccessPoint
)
)
from
topologie.forms
import
EditPortForm
,
NewSwitchForm
,
EditSwitchForm
from
topologie.forms
import
EditPortForm
,
NewSwitchForm
,
EditSwitchForm
from
topologie.forms
import
(
from
topologie.forms
import
(
...
@@ -64,8 +64,8 @@ from topologie.forms import (
...
@@ -64,8 +64,8 @@ from topologie.forms import (
EditModelSwitchForm
,
EditModelSwitchForm
,
EditConstructorSwitchForm
,
EditConstructorSwitchForm
,
CreatePortsForm
,
CreatePortsForm
,
Add
Borne
Form
,
Add
AccessPoint
Form
,
Edit
Borne
Form
Edit
AccessPoint
Form
)
)
from
users.views
import
form
from
users.views
import
form
from
re2o.utils
import
SortTable
from
re2o.utils
import
SortTable
...
@@ -172,29 +172,29 @@ def index_room(request):
...
@@ -172,29 +172,29 @@ def index_room(request):
@
login_required
@
login_required
@
can_view_all
(
Borne
)
@
can_view_all
(
AccessPoint
)
def
index_
borne
(
request
):
def
index_
ap
(
request
):
""" Affichage de l'ensemble des bornes"""
""" Affichage de l'ensemble des bornes"""
borne_list
=
Borne
.
objects
ap_list
=
AccessPoint
.
objects
borne
_list
=
SortTable
.
sort
(
ap
_list
=
SortTable
.
sort
(
borne
_list
,
ap
_list
,
request
.
GET
.
get
(
'col'
),
request
.
GET
.
get
(
'col'
),
request
.
GET
.
get
(
'order'
),
request
.
GET
.
get
(
'order'
),
SortTable
.
TOPOLOGIE_INDEX_BORNE
SortTable
.
TOPOLOGIE_INDEX_BORNE
)
)
pagination_number
=
GeneralOption
.
get_cached_value
(
'pagination_number'
)
pagination_number
=
GeneralOption
.
get_cached_value
(
'pagination_number'
)
paginator
=
Paginator
(
borne
_list
,
pagination_number
)
paginator
=
Paginator
(
ap
_list
,
pagination_number
)
page
=
request
.
GET
.
get
(
'page'
)
page
=
request
.
GET
.
get
(
'page'
)
try
:
try
:
borne
_list
=
paginator
.
page
(
page
)
ap
_list
=
paginator
.
page
(
page
)
except
PageNotAnInteger
:
except
PageNotAnInteger
:
# If page is not an integer, deliver first page.
# If page is not an integer, deliver first page.
borne
_list
=
paginator
.
page
(
1
)
ap
_list
=
paginator
.
page
(
1
)
except
EmptyPage
:
except
EmptyPage
:
# If page is out of range (e.g. 9999), deliver last page of results.
# If page is out of range (e.g. 9999), deliver last page of results.
borne
_list
=
paginator
.
page
(
paginator
.
num_pages
)
ap
_list
=
paginator
.
page
(
paginator
.
num_pages
)
return
render
(
request
,
'topologie/index_
borne
.html'
,
{
return
render
(
request
,
'topologie/index_
ap
.html'
,
{
'
borne_list'
:
borne
_list
'
ap_list'
:
ap
_list
})
})
...
@@ -526,12 +526,12 @@ def edit_switch(request, switch, switch_id):
...
@@ -526,12 +526,12 @@ def edit_switch(request, switch, switch_id):
@
login_required
@
login_required
@
can_create
(
Borne
)
@
can_create
(
AccessPoint
)
def
new_
borne
(
request
):
def
new_
ap
(
request
):
""" Creation d'une
borne
. Cree en meme temps l'interface et la machine
""" Creation d'une
ap
. Cree en meme temps l'interface et la machine
associée. Vue complexe. Appelle successivement les 3 models forms
associée. Vue complexe. Appelle successivement les 3 models forms
adaptés : machine, interface, domain et switch"""
adaptés : machine, interface, domain et switch"""
borne
=
AddBorne
Form
(
ap
=
AddAccessPoint
Form
(
request
.
POST
or
None
,
request
.
POST
or
None
,
user
=
request
.
user
user
=
request
.
user
)
)
...
@@ -542,7 +542,7 @@ def new_borne(request):
...
@@ -542,7 +542,7 @@ def new_borne(request):
domain
=
DomainForm
(
domain
=
DomainForm
(
request
.
POST
or
None
,
request
.
POST
or
None
,
)
)
if
borne
.
is_valid
()
and
machine
.
is_valid
():
if
ap
.
is_valid
()
and
machine
.
is_valid
():
user
=
AssoOption
.
get_cached_value
(
'utilisateur_asso'
)
user
=
AssoOption
.
get_cached_value
(
'utilisateur_asso'
)
if
not
user
:
if
not
user
:
messages
.
error
(
request
,
"L'user association n'existe pas encore,
\
messages
.
error
(
request
,
"L'user association n'existe pas encore,
\
...
@@ -550,29 +550,29 @@ def new_borne(request):
...
@@ -550,29 +550,29 @@ def new_borne(request):
return
redirect
(
reverse
(
'topologie:index'
))
return
redirect
(
reverse
(
'topologie:index'
))
new_machine
=
machine
.
save
(
commit
=
False
)
new_machine
=
machine
.
save
(
commit
=
False
)
new_machine
.
user
=
user
new_machine
.
user
=
user
new_
borne
=
borne
.
save
(
commit
=
False
)
new_
ap
=
ap
.
save
(
commit
=
False
)
domain
.
instance
.
interface_parent
=
new_
borne
domain
.
instance
.
interface_parent
=
new_
ap
if
domain
.
is_valid
():
if
domain
.
is_valid
():
new_domain_instance
=
domain
.
save
(
commit
=
False
)
new_domain_instance
=
domain
.
save
(
commit
=
False
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_machine
.
save
()
new_machine
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
reversion
.
set_comment
(
"Création"
)
new_
borne
.
machine
=
new_machine
new_
ap
.
machine
=
new_machine
with
transaction
.
atomic
(),
reversion
.
create_revision
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_
borne
.
save
()
new_
ap
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
reversion
.
set_comment
(
"Création"
)
new_domain_instance
.
interface_parent
=
new_
borne
new_domain_instance
.
interface_parent
=
new_
ap
with
transaction
.
atomic
(),
reversion
.
create_revision
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_domain_instance
.
save
()
new_domain_instance
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
reversion
.
set_comment
(
"Création"
)
messages
.
success
(
request
,
"La borne a été créé"
)
messages
.
success
(
request
,
"La borne a été créé"
)
return
redirect
(
reverse
(
'topologie:index-
borne
'
))
return
redirect
(
reverse
(
'topologie:index-
ap
'
))
i_mbf_param
=
generate_ipv4_mbf_param
(
borne
,
False
)
i_mbf_param
=
generate_ipv4_mbf_param
(
ap
,
False
)
return
form
({
return
form
({
'topoform'
:
borne
,
'topoform'
:
ap
,
'machineform'
:
machine
,
'machineform'
:
machine
,
'domainform'
:
domain
,
'domainform'
:
domain
,
'i_mbf_param'
:
i_mbf_param
,
'i_mbf_param'
:
i_mbf_param
,
...
@@ -581,32 +581,32 @@ def new_borne(request):
...
@@ -581,32 +581,32 @@ def new_borne(request):
@
login_required
@
login_required
@
can_edit
(
Borne
)
@
can_edit
(
AccessPoint
)
def
edit_
borne
(
request
,
borne
,
borne
_id
):
def
edit_
ap
(
request
,
ap
,
ap
_id
):
""" Edition d'un switch. Permet de chambre nombre de ports,
""" Edition d'un switch. Permet de chambre nombre de ports,
place dans le stack, interface et machine associée"""
place dans le stack, interface et machine associée"""
borne_form
=
EditBorne
Form
(
ap_form
=
EditAccessPoint
Form
(
request
.
POST
or
None
,
request
.
POST
or
None
,
user
=
request
.
user
,
user
=
request
.
user
,
instance
=
borne
instance
=
ap
)
)
machine_form
=
NewMachineForm
(
machine_form
=
NewMachineForm
(
request
.
POST
or
None
,
request
.
POST
or
None
,
user
=
request
.
user
,
user
=
request
.
user
,
instance
=
borne
.
machine
instance
=
ap
.
machine
)
)
domain_form
=
DomainForm
(
domain_form
=
DomainForm
(
request
.
POST
or
None
,
request
.
POST
or
None
,
instance
=
borne
.
domain
instance
=
ap
.
domain
)
)
if
borne
_form
.
is_valid
()
and
machine_form
.
is_valid
():
if
ap
_form
.
is_valid
()
and
machine_form
.
is_valid
():
user
=
AssoOption
.
get_cached_value
(
'utilisateur_asso'
)
user
=
AssoOption
.
get_cached_value
(
'utilisateur_asso'
)
if
not
user
:
if
not
user
:
messages
.
error
(
request
,
"L'user association n'existe pas encore,
\
messages
.
error
(
request
,
"L'user association n'existe pas encore,
\
veuillez le créer ou le linker dans preferences"
)
veuillez le créer ou le linker dans preferences"
)
return
redirect
(
reverse
(
'topologie:index-
borne
'
))
return
redirect
(
reverse
(
'topologie:index-
ap
'
))
new_machine
=
machine_form
.
save
(
commit
=
False
)
new_machine
=
machine_form
.
save
(
commit
=
False
)
new_
borne
=
borne
_form
.
save
(
commit
=
False
)
new_
ap
=
ap
_form
.
save
(
commit
=
False
)
new_domain
=
domain_form
.
save
(
commit
=
False
)
new_domain
=
domain_form
.
save
(
commit
=
False
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_machine
.
save
()
new_machine
.
save
()
...
@@ -616,10 +616,10 @@ def edit_borne(request, borne, borne_id):
...
@@ -616,10 +616,10 @@ def edit_borne(request, borne, borne_id):
field
for
field
in
machine_form
.
changed_data
)
field
for
field
in
machine_form
.
changed_data
)
)
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_
borne
.
save
()
new_
ap
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Champs modifié(s) :
%
s"
%
', '
.
join
(
reversion
.
set_comment
(
"Champs modifié(s) :
%
s"
%
', '
.
join
(
field
for
field
in
borne
_form
.
changed_data
)
field
for
field
in
ap
_form
.
changed_data
)
)
)
reversion
.
set_comment
(
"Création"
)
reversion
.
set_comment
(
"Création"
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
...
@@ -629,10 +629,10 @@ def edit_borne(request, borne, borne_id):
...
@@ -629,10 +629,10 @@ def edit_borne(request, borne, borne_id):
field
for
field
in
domain_form
.
changed_data
)
field
for
field
in
domain_form
.
changed_data
)
)
)
messages
.
success
(
request
,
"La borne a été modifiée"
)
messages
.
success
(
request
,
"La borne a été modifiée"
)
return
redirect
(
reverse
(
'topologie:index-
borne
'
))
return
redirect
(
reverse
(
'topologie:index-
ap
'
))
i_mbf_param
=
generate_ipv4_mbf_param
(
borne
_form
,
False
)
i_mbf_param
=
generate_ipv4_mbf_param
(
ap
_form
,
False
)
return
form
({
return
form
({
'topoform'
:
borne
_form
,
'topoform'
:
ap
_form
,
'machineform'
:
machine_form
,
'machineform'
:
machine_form
,
'domainform'
:
domain_form
,
'domainform'
:
domain_form
,
'i_mbf_param'
:
i_mbf_param
,
'i_mbf_param'
:
i_mbf_param
,
...
...
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