mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 01:03:09 +00:00
Nouvelle gestion acl sur topologie
This commit is contained in:
parent
e24bba8bb8
commit
a022a23f12
14 changed files with 78 additions and 104 deletions
|
@ -67,33 +67,23 @@ class Stack(models.Model):
|
|||
return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
|
||||
de créer un stack"
|
||||
|
||||
def can_edit_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des stack"
|
||||
return True, None
|
||||
|
||||
def can_edit(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des stack"
|
||||
return True, None
|
||||
|
||||
def can_delete_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer une stack"
|
||||
return True, None
|
||||
|
||||
def can_delete(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer une stack"
|
||||
return True, None
|
||||
|
||||
def can_view_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
if not user_request.has_perms(('cableur',)):
|
||||
return False, u"Vous n'avez pas le droit de voir une stack"
|
||||
return True, None
|
||||
|
||||
def can_view(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
if not user_request.has_perms(('cableur',)):
|
||||
return False, u"Vous n'avez pas le droit de voir une stack"
|
||||
return True, None
|
||||
|
||||
|
@ -158,21 +148,11 @@ class Switch(models.Model):
|
|||
return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
|
||||
de créer un switch"
|
||||
|
||||
def can_edit_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des switch"
|
||||
return True, None
|
||||
|
||||
def can_edit(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des switch"
|
||||
return True, None
|
||||
|
||||
def can_delete_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un switch"
|
||||
return True, None
|
||||
|
||||
def can_delete(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un switch"
|
||||
|
@ -253,21 +233,11 @@ class ModelSwitch(models.Model):
|
|||
return False, u"Vous n'avez pas le droit d'éditer des modèle de switchs"
|
||||
return True, None
|
||||
|
||||
def can_edit_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des modèle de switchs"
|
||||
return True, None
|
||||
|
||||
def can_delete(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un modèle switch"
|
||||
return True, None
|
||||
|
||||
def can_delete_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un modèle switch"
|
||||
return True, None
|
||||
|
||||
def can_view(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('cableur',)):
|
||||
return False, u"Vous n'avez pas le droit de voir un modèle switch"
|
||||
|
@ -294,23 +264,12 @@ class ConstructorSwitch(models.Model):
|
|||
return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
|
||||
de créer un constructeur de switch"
|
||||
|
||||
def can_edit_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des\
|
||||
constructeurs de switchs"
|
||||
return True, None
|
||||
|
||||
def can_edit(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des\
|
||||
constructeurs de switchs"
|
||||
return True, None
|
||||
|
||||
def can_delete_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un constructeur"
|
||||
return True, None
|
||||
|
||||
def can_delete(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un constructeur"
|
||||
|
@ -403,21 +362,11 @@ class Port(models.Model):
|
|||
return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
|
||||
de créer un port"
|
||||
|
||||
def can_edit_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des ports"
|
||||
return True, None
|
||||
|
||||
def can_edit(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer des ports"
|
||||
return True, None
|
||||
|
||||
def can_delete_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un port"
|
||||
return True, None
|
||||
|
||||
def can_delete(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer un port"
|
||||
|
@ -494,21 +443,11 @@ class Room(models.Model):
|
|||
return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
|
||||
de créer une chambre"
|
||||
|
||||
def can_edit_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer une chambre"
|
||||
return True, None
|
||||
|
||||
def can_edit(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit d'éditer une chambre"
|
||||
return True, None
|
||||
|
||||
def can_delete_all(user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer une chambre"
|
||||
return True, None
|
||||
|
||||
def can_delete(self, user_request, *args, **kwargs):
|
||||
if not user_request.has_perms(('infra',)):
|
||||
return False, u"Vous n'avez pas le droit de supprimer une chambre"
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
|
||||
{% if room_list.paginator %}
|
||||
{% include "pagination.html" with list=room_list %}
|
||||
{% endif %}
|
||||
|
@ -42,14 +44,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'room' room.pk %}">
|
||||
<i class="glyphicon glyphicon-time"></i>
|
||||
</a>
|
||||
{% if is_infra %}
|
||||
{% can_edit room %}
|
||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-room' room.id %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_delete room %}
|
||||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-room' room.id %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
|
||||
{% if constructor_switch_list.paginator %}
|
||||
{% include "pagination.html" with list=constructor_switch_list %}
|
||||
{% endif %}
|
||||
|
@ -40,14 +42,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'constructor_switch' constructor_switch.pk %}">
|
||||
<i class="glyphicon glyphicon-time"></i>
|
||||
</a>
|
||||
{% if is_infra %}
|
||||
{% can_edit constructor_switch %}
|
||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-constructor-switch' constructor_switch.id %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_delete constructor_switch %}
|
||||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-constructor-switch' constructor_switch.id %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
|
||||
{% if model_switch_list.paginator %}
|
||||
{% include "pagination.html" with list=model_switch_list %}
|
||||
{% endif %}
|
||||
|
@ -42,14 +44,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'model_switch' model_switch.pk %}">
|
||||
<i class="glyphicon glyphicon-time"></i>
|
||||
</a>
|
||||
{% if is_infra %}
|
||||
{% can_edit model_switch %}
|
||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-model-switch' model_switch.id %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_delete model_switch %}
|
||||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-model-switch' model_switch.id %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -60,14 +62,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'port' port.pk %}">
|
||||
<i class="glyphicon glyphicon-time"></i>
|
||||
</a>
|
||||
{% if is_infra %}
|
||||
{% can_edit port %}
|
||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-port' port.id %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_delete port %}
|
||||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-port' port.pk %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -46,14 +48,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'stack' stack.pk %}">
|
||||
<i class="glyphicon glyphicon-time"></i>
|
||||
</a>
|
||||
{% if is_infra %}
|
||||
{% can_edit stack %}
|
||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-stack' stack.id %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_delete stack %}
|
||||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
@ -67,14 +71,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'stack' stack.pk %}">
|
||||
<i class="glyphicon glyphicon-time"></i>
|
||||
</a>
|
||||
{% if is_infra %}
|
||||
{% can_edit stack %}
|
||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-stack' stack.id %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_delete stack %}
|
||||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
|
||||
{% if switch_list.paginator %}
|
||||
{% include "pagination.html" with list=switch_list %}
|
||||
{% endif %}
|
||||
|
@ -56,11 +58,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<td>{{switch.details}}</td>
|
||||
<td class="text-right">
|
||||
{% include 'buttons/history.html' with href='topologie:history' name='switch' id=switch.pk%}
|
||||
{% if is_infra %}
|
||||
{% include 'buttons/edit.html' with href='topologie:edit-switch' id=switch.pk %}
|
||||
{% can_edit switch %}
|
||||
{% include 'buttons/edit.html' with href='topologie:edit-switch' id=switch.pk %}
|
||||
{% acl_end %}
|
||||
{% can_delete switch %}
|
||||
{% include 'buttons/suppr.html' with href='machines:del-interface' id=switch.switch_interface.id %}
|
||||
{% acl_end %}
|
||||
{% can_create Port %}
|
||||
{% include 'buttons/add.html' with href='topologie:create-ports' id=switch.pk desc='Création de ports'%}
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -39,14 +41,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'stack' stack.pk %}">
|
||||
<i class="glyphicon glyphicon-time"></i>
|
||||
</a>
|
||||
{% if is_infra %}
|
||||
{% can_edit stack %}
|
||||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-stack' stack.id %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_delete stack %}
|
||||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -24,15 +24,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% endcomment %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
{% load acl %}
|
||||
|
||||
{% block title %}Switchs{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Switchs</h2>
|
||||
{% if is_infra %}
|
||||
{% can_create Switch %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-switch' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un switch</a>
|
||||
<hr>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -24,21 +24,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% endcomment %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
{% load acl %}
|
||||
|
||||
{% block title %}Modèles de switches{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Modèles de switches</h2>
|
||||
{% if is_infra %}
|
||||
{% can_create ModelSwitch %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-model-switch' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un modèle</a>
|
||||
<hr>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
{% include "topologie/aff_model_switch.html" with model_switch_list=model_switch_list %}
|
||||
<h2>Constructeurs de switches</h2>
|
||||
{% if is_infra %}
|
||||
{% can_create ConstructorSwitch %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-constructor-switch' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un constructeur</a>
|
||||
<hr>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
{% include "topologie/aff_constructor_switch.html" with constructor_switch_list=constructor_switch_list %}
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -24,16 +24,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% endcomment %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
{% load acl %}
|
||||
|
||||
{% block title %}Ports du switch{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Switch {{ nom_switch }}</h2>
|
||||
{% if is_infra %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-switch' id_switch %}"><i class="glyphicon glyphicon-edit"></i> Editer</a>
|
||||
{% can_create Port %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-port' id_switch %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un port</a>
|
||||
{% acl_end %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:create-ports' id_switch %}"><i class="glyphicon glyphicon-plus"></i> Ajouter des ports</a>
|
||||
{% endif %}
|
||||
{% include "topologie/aff_port.html" with port_list=port_list %}
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -24,15 +24,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% endcomment %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
{% load acl %}
|
||||
|
||||
{% block title %}Chambres{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Chambres</h2>
|
||||
{% if is_infra %}
|
||||
{% can_create Room %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-room' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une chambre</a>
|
||||
<hr>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
{% include "topologie/aff_chambres.html" with room_list=room_list %}
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -24,14 +24,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% endcomment %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
{% load acl %}
|
||||
|
||||
{% block title %}Stacks{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Stacks</h2>
|
||||
{% if is_infra %}
|
||||
{% can_create Stack %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-stack' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une stack</a>
|
||||
{% endif %}
|
||||
{% acl_end %}
|
||||
{% include "topologie/aff_stacks.html" with stack_list=stack_list %}
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -70,7 +70,8 @@ from re2o.utils import (
|
|||
can_create,
|
||||
can_edit,
|
||||
can_delete,
|
||||
can_view
|
||||
can_view,
|
||||
can_view_all,
|
||||
)
|
||||
from machines.forms import (
|
||||
DomainForm,
|
||||
|
@ -84,7 +85,7 @@ from preferences.models import AssoOption, GeneralOption
|
|||
|
||||
|
||||
@login_required
|
||||
@permission_required('cableur')
|
||||
@can_view_all(Switch)
|
||||
def index(request):
|
||||
""" Vue d'affichage de tous les swicthes"""
|
||||
switch_list = Switch.objects\
|
||||
|
@ -178,14 +179,10 @@ def history(request, object_name, object_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@permission_required('cableur')
|
||||
def index_port(request, switch_id):
|
||||
@can_view_all(Port)
|
||||
@can_view(Switch)
|
||||
def index_port(request, switch, switch_id):
|
||||
""" Affichage de l'ensemble des ports reliés à un switch particulier"""
|
||||
try:
|
||||
switch = Switch.objects.get(pk=switch_id)
|
||||
except Switch.DoesNotExist:
|
||||
messages.error(request, u"Switch inexistant")
|
||||
return redirect(reverse('topologie:index'))
|
||||
port_list = Port.objects.filter(switch=switch)\
|
||||
.select_related('room')\
|
||||
.select_related('machine_interface__domain__extension')\
|
||||
|
@ -208,7 +205,7 @@ def index_port(request, switch_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@permission_required('cableur')
|
||||
@can_view_all(Room)
|
||||
def index_room(request):
|
||||
""" Affichage de l'ensemble des chambres"""
|
||||
room_list = Room.objects
|
||||
|
@ -236,7 +233,7 @@ def index_room(request):
|
|||
|
||||
|
||||
@login_required
|
||||
@permission_required('infra')
|
||||
@can_view_all(Stack)
|
||||
def index_stack(request):
|
||||
"""Affichage de la liste des stacks (affiche l'ensemble des switches)"""
|
||||
stack_list = Stack.objects\
|
||||
|
@ -253,7 +250,8 @@ def index_stack(request):
|
|||
|
||||
|
||||
@login_required
|
||||
@permission_required('cableur')
|
||||
@can_view_all(ModelSwitch)
|
||||
@can_view_all(ConstructorSwitch)
|
||||
def index_model_switch(request):
|
||||
""" Affichage de l'ensemble des modèles de switches"""
|
||||
model_switch_list = ModelSwitch.objects
|
||||
|
|
Loading…
Reference in a new issue