Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nounous
re2o
Commits
34426809
Commit
34426809
authored
Oct 26, 2016
by
chirac
Browse files
Modifie le model switch
parent
62721032
Changes
8
Hide whitespace changes
Inline
Side-by-side
machines/forms.py
View file @
34426809
...
...
@@ -100,7 +100,7 @@ class ExtensionForm(ModelForm):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
ExtensionForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'name'
].
label
=
'Ex
s
tension à ajouter'
self
.
fields
[
'name'
].
label
=
'Extension à ajouter'
class
DelExtensionForm
(
ModelForm
):
extensions
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Extension
.
objects
.
all
(),
label
=
"Extensions actuelles"
,
widget
=
forms
.
CheckboxSelectMultiple
)
...
...
machines/migrations/0026_auto_20161026_1348.py
0 → 100644
View file @
34426809
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'machines'
,
'0025_auto_20161023_0038'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'interface'
,
name
=
'dns'
,
field
=
models
.
CharField
(
unique
=
True
,
max_length
=
255
,
help_text
=
'Obligatoire et unique, ne doit pas comporter de points'
),
),
]
topologie/admin.py
View file @
34426809
...
...
@@ -5,7 +5,7 @@ from reversion.admin import VersionAdmin
from
.models
import
Port
,
Room
,
Switch
class
SwitchAdmin
(
VersionAdmin
):
list_display
=
(
'
building
'
,
'number'
,
'details'
)
list_display
=
(
'
switch_interface'
,
'location
'
,
'number'
,
'details'
)
class
PortAdmin
(
VersionAdmin
):
list_display
=
(
'switch'
,
'port'
,
'room'
,
'machine_interface'
,
'details'
)
...
...
topologie/forms.py
View file @
34426809
...
...
@@ -14,14 +14,19 @@ class AddPortForm(ModelForm):
class
Meta
(
PortForm
.
Meta
):
fields
=
[
'port'
,
'room'
,
'machine_interface'
,
'related'
,
'details'
]
class
SwitchForm
(
ModelForm
):
class
Edit
SwitchForm
(
ModelForm
):
class
Meta
:
model
=
Switch
fields
=
'__all__'
class
EditSwitchForm
(
ModelForm
):
class
Meta
(
SwitchForm
.
Meta
):
fields
=
[
'building'
,
'number'
,
'details'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
EditSwitchForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'location'
].
label
=
'Localisation'
self
.
fields
[
'number'
].
label
=
'Nombre de ports'
class
NewSwitchForm
(
ModelForm
):
class
Meta
(
EditSwitchForm
.
Meta
):
fields
=
[
'location'
,
'number'
,
'details'
]
class
EditRoomForm
(
ModelForm
):
class
Meta
:
...
...
topologie/migrations/0019_auto_20161026_1348.py
0 → 100644
View file @
34426809
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'machines'
,
'0026_auto_20161026_1348'
),
(
'topologie'
,
'0018_room_details'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'switch'
,
name
=
'location'
,
field
=
models
.
CharField
(
default
=
'test'
,
max_length
=
255
),
preserve_default
=
False
,
),
migrations
.
AddField
(
model_name
=
'switch'
,
name
=
'switch_interface'
,
field
=
models
.
OneToOneField
(
default
=
1
,
to
=
'machines.Interface'
),
preserve_default
=
False
,
),
migrations
.
AlterUniqueTogether
(
name
=
'switch'
,
unique_together
=
set
([]),
),
migrations
.
RemoveField
(
model_name
=
'switch'
,
name
=
'building'
,
),
]
topologie/models.py
View file @
34426809
...
...
@@ -16,15 +16,13 @@ def clean_port_related(port):
related_port
.
save
()
class
Switch
(
models
.
Model
):
building
=
models
.
CharField
(
max_length
=
10
)
switch_interface
=
models
.
OneToOneField
(
'machines.Interface'
,
on_delete
=
models
.
CASCADE
)
location
=
models
.
CharField
(
max_length
=
255
)
number
=
models
.
IntegerField
()
details
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
class
Meta
:
unique_together
=
(
'building'
,
'number'
)
def
__str__
(
self
):
return
str
(
self
.
building
)
+
str
(
self
.
number
)
return
str
(
self
.
location
)
class
Port
(
models
.
Model
):
switch
=
models
.
ForeignKey
(
'Switch'
,
related_name
=
"ports"
)
...
...
topologie/templates/topologie/aff_switch.html
View file @
34426809
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Bâtiment
</th>
<th>
Numero
</th>
<th>
Dns
</th>
<th>
Ipv4
</th>
<th>
Localisation
</th>
<th>
Nombre de ports
</th>
<th>
Détails
</th>
<th></th>
</tr>
</thead>
{% for switch in switch_list %}
<tr>
<td>
{{switch.building}}
</td>
<td>
{{switch.switch_interface.dns}}
</td>
<td>
{{switch.switch_interface.ipv4}}
</td>
<td>
{{switch.location}}
</td>
<td>
{{switch.number}}
</td>
<td>
{{switch.details}}
</td>
<td><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'topologie:index-port' switch.pk %}"
><i
class=
"glyphicon glyphicon-cog"
></i>
Configurer
</a>
...
...
topologie/views.py
View file @
34426809
...
...
@@ -15,7 +15,7 @@ from re2o.settings import PAGINATION_NUMBER
@
login_required
@
permission_required
(
'cableur'
)
def
index
(
request
):
switch_list
=
Switch
.
objects
.
order_by
(
'
building'
,
'number
'
)
switch_list
=
Switch
.
objects
.
order_by
(
'
location
'
)
return
render
(
request
,
'topologie/index.html'
,
{
'switch_list'
:
switch_list
})
@
login_required
...
...
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