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
7bd2e318
Commit
7bd2e318
authored
Jul 21, 2016
by
chirac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gestion de l'historique dans topologie
parent
13d4e2e7
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
99 additions
and
13 deletions
+99
-13
re2o/templates/re2o/aff_history.html
re2o/templates/re2o/aff_history.html
+16
-0
re2o/templates/re2o/history.html
re2o/templates/re2o/history.html
+12
-0
topologie/admin.py
topologie/admin.py
+4
-3
topologie/models.py
topologie/models.py
+1
-0
topologie/templates/topologie/aff_chambres.html
topologie/templates/topologie/aff_chambres.html
+2
-1
topologie/templates/topologie/aff_port.html
topologie/templates/topologie/aff_port.html
+2
-1
topologie/templates/topologie/aff_switch.html
topologie/templates/topologie/aff_switch.html
+2
-1
topologie/urls.py
topologie/urls.py
+3
-0
topologie/views.py
topologie/views.py
+57
-7
No files found.
re2o/templates/re2o/aff_history.html
0 → 100644
View file @
7bd2e318
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Date
</th>
<th>
Cableur
</th>
<th>
Commentaire
</th>
</tr>
</thead>
{% for rev in reversions %}
<tr>
<td>
{{ rev.revision.date_created }}
</td>
<td>
{{ rev.revision.user }}
</td>
<td>
{{ rev.revision.comment }}
</td>
</tr>
{% endfor %}
</table>
re2o/templates/re2o/history.html
0 → 100644
View file @
7bd2e318
{% extends "re2o/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Historique{% endblock %}
{% block content %}
<h2>
Historique de {{ object }}
</h2>
{% include "re2o/aff_history.html" with reversions=reversions %}
<br
/>
<br
/>
<br
/>
{% endblock %}
topologie/admin.py
View file @
7bd2e318
from
django.contrib
import
admin
from
reversion.admin
import
VersionAdmin
from
.models
import
Port
,
Room
,
Switch
class
SwitchAdmin
(
admin
.
Model
Admin
):
class
SwitchAdmin
(
Version
Admin
):
list_display
=
(
'building'
,
'number'
,
'details'
)
class
PortAdmin
(
admin
.
Model
Admin
):
class
PortAdmin
(
Version
Admin
):
list_display
=
(
'switch'
,
'port'
,
'room'
,
'machine_interface'
,
'details'
)
class
RoomAdmin
(
admin
.
Model
Admin
):
class
RoomAdmin
(
Version
Admin
):
list_display
=
(
'name'
,
'details'
)
admin
.
site
.
register
(
Port
,
PortAdmin
)
...
...
topologie/models.py
View file @
7bd2e318
...
...
@@ -3,6 +3,7 @@ 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
import
reversion
def
make_port_related
(
port
):
related_port
=
port
.
related
...
...
topologie/templates/topologie/aff_chambres.html
View file @
7bd2e318
...
...
@@ -11,7 +11,8 @@
<td>
{{room.name}}
</td>
<td>
{{room.details}}
</td>
<td>
{% if is_infra %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'topologie:edit-room' room.id %}"
><i
class=
"glyphicon glyphicon-random"
></i>
Editer
</a>
<a
class=
"btn btn-danger btn-sm"
role=
"button"
href=
"{% url 'topologie:del-room' room.id %}"
><i
class=
"glyphicon glyphicon-trash"
></i>
Supprimer
</a>
{% endif %}
</td>
<a
class=
"btn btn-danger btn-sm"
role=
"button"
href=
"{% url 'topologie:del-room' room.id %}"
><i
class=
"glyphicon glyphicon-trash"
></i>
Supprimer
</a>
{% endif %}
<a
class=
"btn btn-info btn-sm"
role=
"button"
href=
"{% url 'topologie:history' 'room' room.pk %}"
><i
class=
"glyphicon glyphicon-repeat"
></i>
Historique
</a></td>
</tr>
{% endfor %}
</table>
topologie/templates/topologie/aff_port.html
View file @
7bd2e318
...
...
@@ -16,7 +16,8 @@
<td>
{{ port.machine_interface }}
</td>
<td>
{{ port.related }}
</td>
<td>
{{ port.details }}
</td>
<td>
{% if is_infra %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'topologie:edit-port' port.id %}"
><i
class=
"glyphicon glyphicon-random"
></i>
Editer
</a>
{% endif %}
</td>
<td>
{% if is_infra %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'topologie:edit-port' port.id %}"
><i
class=
"glyphicon glyphicon-random"
></i>
Editer
</a>
{% endif %}
<a
class=
"btn btn-info btn-sm"
role=
"button"
href=
"{% url 'topologie:history' 'port' port.pk %}"
><i
class=
"glyphicon glyphicon-repeat"
></i>
Historique
</a></td>
</tr>
{% endfor %}
</table>
topologie/templates/topologie/aff_switch.html
View file @
7bd2e318
...
...
@@ -12,7 +12,8 @@
<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-cog"
></i>
Configurer
</a></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>
<a
class=
"btn btn-info btn-sm"
role=
"button"
href=
"{% url 'topologie:history' 'switch' switch.pk %}"
><i
class=
"glyphicon glyphicon-repeat"
></i>
Historique
</a></td>
</tr>
{% endfor %}
</table>
topologie/urls.py
View file @
7bd2e318
...
...
@@ -10,6 +10,9 @@ urlpatterns = [
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
'^switch/(?P<switch_id>[0-9]+)$'
,
views
.
index_port
,
name
=
'index-port'
),
url
(
r
'^history/(?P<object>switch)/(?P<id>[0-9]+)$'
,
views
.
history
,
name
=
'history'
),
url
(
r
'^history/(?P<object>port)/(?P<id>[0-9]+)$'
,
views
.
history
,
name
=
'history'
),
url
(
r
'^history/(?P<object>room)/(?P<id>[0-9]+)$'
,
views
.
history
,
name
=
'history'
),
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
'^edit_switch/(?P<switch_id>[0-9]+)$'
,
views
.
edit_switch
,
name
=
'edit-switch'
),
...
...
topologie/views.py
View file @
7bd2e318
...
...
@@ -2,6 +2,8 @@ from django.shortcuts import render, redirect
from
django.contrib
import
messages
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.db
import
IntegrityError
from
django.db
import
transaction
from
reversion
import
revisions
as
reversion
from
topologie.models
import
Switch
,
Port
,
Room
from
topologie.forms
import
EditPortForm
,
EditSwitchForm
,
AddPortForm
,
EditRoomForm
...
...
@@ -13,6 +15,33 @@ def index(request):
switch_list
=
Switch
.
objects
.
order_by
(
'building'
,
'number'
)
return
render
(
request
,
'topologie/index.html'
,
{
'switch_list'
:
switch_list
})
@
login_required
@
permission_required
(
'cableur'
)
def
history
(
request
,
object
,
id
):
if
object
==
'switch'
:
try
:
object_instance
=
Switch
.
objects
.
get
(
pk
=
id
)
except
Switch
.
DoesNotExist
:
messages
.
error
(
request
,
"Switch inexistant"
)
return
redirect
(
"/topologie/"
)
elif
object
==
'port'
:
try
:
object_instance
=
Port
.
objects
.
get
(
pk
=
id
)
except
Port
.
DoesNotExist
:
messages
.
error
(
request
,
"Port inexistant"
)
return
redirect
(
"/topologie/"
)
elif
object
==
'room'
:
try
:
object_instance
=
Room
.
objects
.
get
(
pk
=
id
)
except
Room
.
DoesNotExist
:
messages
.
error
(
request
,
"Chambre inexistante"
)
return
redirect
(
"/topologie/"
)
else
:
messages
.
error
(
request
,
"Objet inconnu"
)
return
redirect
(
"/topologie/"
)
reversions
=
reversion
.
get_for_object
(
object_instance
)
return
render
(
request
,
're2o/history.html'
,
{
'reversions'
:
reversions
,
'object'
:
object_instance
})
@
login_required
@
permission_required
(
'cableur'
)
def
index_port
(
request
,
switch_id
):
...
...
@@ -43,7 +72,10 @@ def new_port(request, switch_id):
port
=
port
.
save
(
commit
=
False
)
port
.
switch
=
switch
try
:
with
transaction
.
atomic
(),
reversion
.
create_revision
():
port
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
messages
.
success
(
request
,
"Port ajouté"
)
except
IntegrityError
:
messages
.
error
(
request
,
"Ce port existe déjà"
)
...
...
@@ -60,7 +92,10 @@ def edit_port(request, port_id):
return
redirect
(
"/topologie/"
)
port
=
EditPortForm
(
request
.
POST
or
None
,
instance
=
port
)
if
port
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
port
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Champs modifié(s) : %s"
%
', '
.
join
(
field
for
field
in
port
.
changed_data
))
messages
.
success
(
request
,
"Le port a bien été modifié"
)
return
redirect
(
"/topologie/"
)
return
form
({
'topoform'
:
port
},
'topologie/topo.html'
,
request
)
...
...
@@ -70,7 +105,10 @@ def edit_port(request, port_id):
def
new_switch
(
request
):
switch
=
EditSwitchForm
(
request
.
POST
or
None
)
if
switch
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
switch
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
messages
.
success
(
request
,
"Le switch a été créé"
)
return
redirect
(
"/topologie/"
)
return
form
({
'topoform'
:
switch
},
'topologie/topo.html'
,
request
)
...
...
@@ -85,7 +123,10 @@ def edit_switch(request, switch_id):
return
redirect
(
"/topologie/"
)
switch
=
EditSwitchForm
(
request
.
POST
or
None
,
instance
=
switch
)
if
switch
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
switch
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Champs modifié(s) : %s"
%
', '
.
join
(
field
for
field
in
switch
.
changed_data
))
messages
.
success
(
request
,
"Le switch a bien été modifié"
)
return
redirect
(
"/topologie/"
)
return
form
({
'topoform'
:
switch
},
'topologie/topo.html'
,
request
)
...
...
@@ -95,7 +136,10 @@ def edit_switch(request, switch_id):
def
new_room
(
request
):
room
=
EditRoomForm
(
request
.
POST
or
None
)
if
room
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
room
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
messages
.
success
(
request
,
"La chambre a été créé"
)
return
redirect
(
"/topologie/index_room/"
)
return
form
({
'topoform'
:
room
},
'topologie/topo.html'
,
request
)
...
...
@@ -110,7 +154,10 @@ def edit_room(request, room_id):
return
redirect
(
"/topologie/index_room/"
)
room
=
EditRoomForm
(
request
.
POST
or
None
,
instance
=
room
)
if
room
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
room
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Champs modifié(s) : %s"
%
', '
.
join
(
field
for
field
in
room
.
changed_data
))
messages
.
success
(
request
,
"La chambre a bien été modifiée"
)
return
redirect
(
"/topologie/index_room/"
)
return
form
({
'topoform'
:
room
},
'topologie/topo.html'
,
request
)
...
...
@@ -124,7 +171,10 @@ def del_room(request, room_id):
messages
.
error
(
request
,
u
"Chambre inexistante"
)
return
redirect
(
"/topologie/index_room/"
)
if
request
.
method
==
"POST"
:
with
transaction
.
atomic
(),
reversion
.
create_revision
():
room
.
delete
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Destruction"
)
messages
.
success
(
request
,
"La chambre/prise a été détruite"
)
return
redirect
(
"/topologie/index_room/"
)
return
form
({
'objet'
:
room
,
'objet_name'
:
'Chambre'
},
'topologie/delete.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