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
88050397
Commit
88050397
authored
Jul 06, 2016
by
Dalahro
Browse files
Affichage de la topologie
Modification d'un port
parent
db638966
Changes
12
Hide whitespace changes
Inline
Side-by-side
re2o/urls.py
View file @
88050397
...
...
@@ -24,5 +24,6 @@ urlpatterns = [
url
(
r
'^search/'
,
include
(
'search.urls'
,
namespace
=
'search'
)),
url
(
r
'^cotisations/'
,
include
(
'cotisations.urls'
,
namespace
=
'cotisations'
)),
url
(
r
'^machines/'
,
include
(
'machines.urls'
,
namespace
=
'machines'
)),
url
(
r
'^topologie/'
,
include
(
'topologie.urls'
,
namespace
=
'topologie'
)),
#url(r'^logs/', include('logs.urls', namespace='logs')),
]
templates/base.html
View file @
88050397
...
...
@@ -30,7 +30,7 @@
<li><a
href=
"{% url "
users:index
"
%}"
>
Adhérents
</a></li>
<li><a
href=
"{% url "
machines:index
"
%}"
>
Machines
</a></li>
<li><a
href=
"{% url "
cotisations:index
"
%}"
>
Cotisations
</a></li>
<li><a
href=
"
#
"
>
Topologie
</a></li>
<li><a
href=
"
{% url "
topologie:index
"
%}
"
>
Topologie
</a></li>
<li><a
href=
"#"
>
Statistiques
</a></li>
</ul>
<div
class=
"col-sm-3 col-md-3 navbar-right"
>
...
...
topologie/forms.py
0 → 100644
View file @
88050397
from
.models
import
Port
from
django.forms
import
ModelForm
,
Form
class
PortForm
(
ModelForm
):
class
Meta
:
model
=
Port
fields
=
'__all__'
class
EditPortForm
(
ModelForm
):
class
Meta
(
PortForm
.
Meta
):
fields
=
[
'room'
,
'machine_interface'
,
'related'
,
'details'
]
topologie/models.py
View file @
88050397
from
django.db
import
models
from
django.forms
import
ModelForm
,
Form
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.contenttypes.fields
import
GenericForeignKey
from
django.core.exceptions
import
ValidationError
...
...
@@ -27,10 +28,10 @@ class Switch(models.Model):
class
Port
(
models
.
Model
):
switch
=
models
.
ForeignKey
(
Switch
,
related_name
=
"ports"
)
port
=
models
.
IntegerField
()
details
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
room
=
models
.
ForeignKey
(
'Room'
,
on_delete
=
models
.
PROTECT
,
blank
=
True
,
null
=
True
)
machine_interface
=
models
.
OneToOneField
(
'machines.Interface'
,
on_delete
=
models
.
PROTECT
,
blank
=
True
,
null
=
True
)
related
=
models
.
OneToOneField
(
'self'
,
null
=
True
,
blank
=
True
,
related_name
=
'related_port'
)
details
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
class
Meta
:
unique_together
=
(
'switch'
,
'port'
)
...
...
topologie/templates/topologie/aff_port.html
0 → 100644
View file @
88050397
<h2>
Switch {% if port_list.0 %}{{ port_list.0.switch }}{% endif %}
</h2>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Port
</th>
<th>
Room
</th>
<th>
Interface machine
</th>
<th>
Related
</th>
<th>
Détails
</th>
<th></th>
</tr>
</thead>
{% for port in port_list %}
<tr>
<td>
{{ port.port }}
</td>
<td>
{{ port.room }}
</td>
<td>
{{ port.machine_interface }}
</td>
<td>
{{ port.related }}
</td>
<td>
{{ port.details }}
</td>
<td><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'topologie:edit-port' port.id %}"
><i
class=
"glyphicon glyphicon-random"
></i>
Editer
</a></td>
</tr>
{% endfor %}
</table>
topologie/templates/topologie/aff_switch.html
0 → 100644
View file @
88050397
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Bâtiment
</th>
<th>
Numero
</th>
<th>
Détails
</th>
<th></th>
</tr>
</thead>
{% for switch in switch_list %}
<tr>
<td>
{{switch.building}}
</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-list-alt"
></i>
Editer
</a></td>
</tr>
{% endfor %}
</table>
topologie/templates/topologie/index.html
0 → 100644
View file @
88050397
{% extends "topologie/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Switchs{% endblock %}
{% block content %}
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
<br
/>
<br
/>
<br
/>
{% endblock %}
topologie/templates/topologie/index_p.html
0 → 100644
View file @
88050397
{% extends "topologie/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Ports du switch{% endblock %}
{% block content %}
{% include "topologie/aff_port.html" with port_list=port_list %}
<br
/>
<br
/>
<br
/>
{% endblock %}
topologie/templates/topologie/port.html
0 → 100644
View file @
88050397
{% extends "topologie/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Création et modificationd 'utilisateur{% endblock %}
{% block content %}
{% bootstrap_form_errors topoform %}
<form
class=
"form"
method=
"post"
>
{% csrf_token %}
{% bootstrap_form topoform %}
{%bootstrap_button "Créer ou modifier" button_type="submit" icon="ok" %}
</form>
<br
/>
<br
/>
<br
/>
{% endblock %}
topologie/templates/topologie/sidebar.html
0 → 100644
View file @
88050397
{% extends "base.html" %}
{% block sidebar %}
<p><a
href=
"{% url "
topologie:index
"
%}"
>
Liste des switchs
</a></p>
{% endblock %}
topologie/urls.py
0 → 100644
View file @
88050397
from
django.conf.urls
import
url
from
.
import
views
urlpatterns
=
[
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^switch/(?P<switch_id>[0-9]+)$'
,
views
.
index_port
,
name
=
'index-port'
),
url
(
r
'^edit_port/(?P<port_id>[0-9]+)$'
,
views
.
edit_port
,
name
=
'edit-port'
),
]
topologie/views.py
View file @
88050397
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.contrib
import
messages
# Create your views here.
from
topologie.models
import
Switch
,
Port
from
topologie.forms
import
EditPortForm
from
users.views
import
form
def
index
(
request
):
switch_list
=
Switch
.
objects
.
order_by
(
'building'
,
'number'
)
return
render
(
request
,
'topologie/index.html'
,
{
'switch_list'
:
switch_list
})
def
index_port
(
request
,
switch_id
):
try
:
switch
=
Switch
.
objects
.
get
(
pk
=
switch_id
)
except
Switch
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Switch inexistant"
)
return
redirect
(
"/topologie/"
)
port_list
=
Port
.
objects
.
filter
(
switch
=
switch
).
order_by
(
'port'
)
return
render
(
request
,
'topologie/index_p.html'
,
{
'port_list'
:
port_list
})
def
edit_port
(
request
,
port_id
):
try
:
port
=
Port
.
objects
.
get
(
pk
=
port_id
)
except
Port
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Port inexistant"
)
return
redirect
(
"/topologie/"
)
port
=
EditPortForm
(
request
.
POST
or
None
,
instance
=
port
)
if
port
.
is_valid
():
port
.
save
()
messages
.
success
(
request
,
"Le port a bien été modifié"
)
return
redirect
(
"/topologie"
)
return
form
({
'topoform'
:
port
},
'topologie/port.html'
,
request
)
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