8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-25 00:13:45 +00:00

Nouvelle gestion acl sur topologie

This commit is contained in:
Gabriel Detraz 2017-12-27 23:07:05 +01:00 committed by root
parent e24bba8bb8
commit a022a23f12
14 changed files with 78 additions and 104 deletions

View file

@ -67,33 +67,23 @@ class Stack(models.Model):
return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\ return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
de créer un stack" 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): def can_edit(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit d'éditer des stack" return False, u"Vous n'avez pas le droit d'éditer des stack"
return True, None 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): def can_delete(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit de supprimer une stack" return False, u"Vous n'avez pas le droit de supprimer une stack"
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_perms(('infra',)): if not user_request.has_perms(('cableur',)):
return False, u"Vous n'avez pas le droit de voir une stack" return False, u"Vous n'avez pas le droit de voir une stack"
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_perms(('infra',)): if not user_request.has_perms(('cableur',)):
return False, u"Vous n'avez pas le droit de voir une stack" return False, u"Vous n'avez pas le droit de voir une stack"
return True, None return True, None
@ -158,21 +148,11 @@ class Switch(models.Model):
return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\ return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
de créer un switch" 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): def can_edit(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit d'éditer des switch" return False, u"Vous n'avez pas le droit d'éditer des switch"
return True, None 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): def can_delete(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit de supprimer un switch" 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 False, u"Vous n'avez pas le droit d'éditer des modèle de switchs"
return True, None 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): def can_delete(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit de supprimer un modèle switch" return False, u"Vous n'avez pas le droit de supprimer un modèle switch"
return True, None 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): def can_view(self, user_request, *args, **kwargs):
if not user_request.has_perms(('cableur',)): if not user_request.has_perms(('cableur',)):
return False, u"Vous n'avez pas le droit de voir un modèle switch" 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\ return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
de créer un constructeur de switch" 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): def can_edit(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit d'éditer des\ return False, u"Vous n'avez pas le droit d'éditer des\
constructeurs de switchs" constructeurs de switchs"
return True, None 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): def can_delete(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit de supprimer un constructeur" 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\ return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
de créer un port" 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): def can_edit(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit d'éditer des ports" return False, u"Vous n'avez pas le droit d'éditer des ports"
return True, None 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): def can_delete(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit de supprimer un port" 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\ return user_request.has_perms(('infra',)) , u"Vous n'avez pas le droit\
de créer une chambre" 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): def can_edit(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit d'éditer une chambre" return False, u"Vous n'avez pas le droit d'éditer une chambre"
return True, None 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): def can_delete(self, user_request, *args, **kwargs):
if not user_request.has_perms(('infra',)): if not user_request.has_perms(('infra',)):
return False, u"Vous n'avez pas le droit de supprimer une chambre" return False, u"Vous n'avez pas le droit de supprimer une chambre"

View file

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load acl %}
{% if room_list.paginator %} {% if room_list.paginator %}
{% include "pagination.html" with list=room_list %} {% include "pagination.html" with list=room_list %}
{% endif %} {% 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 %}"> <a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'room' room.pk %}">
<i class="glyphicon glyphicon-time"></i> <i class="glyphicon glyphicon-time"></i>
</a> </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 %}"> <a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-room' room.id %}">
<i class="glyphicon glyphicon-edit"></i> <i class="glyphicon glyphicon-edit"></i>
</a> </a>
{% acl_end %}
{% can_delete room %}
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-room' room.id %}"> <a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-room' room.id %}">
<i class="glyphicon glyphicon-trash"></i> <i class="glyphicon glyphicon-trash"></i>
</a> </a>
{% endif %} {% acl_end %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load acl %}
{% if constructor_switch_list.paginator %} {% if constructor_switch_list.paginator %}
{% include "pagination.html" with list=constructor_switch_list %} {% include "pagination.html" with list=constructor_switch_list %}
{% endif %} {% 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 %}"> <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> <i class="glyphicon glyphicon-time"></i>
</a> </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 %}"> <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> <i class="glyphicon glyphicon-edit"></i>
</a> </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 %}"> <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> <i class="glyphicon glyphicon-trash"></i>
</a> </a>
{% endif %} {% acl_end %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load acl %}
{% if model_switch_list.paginator %} {% if model_switch_list.paginator %}
{% include "pagination.html" with list=model_switch_list %} {% include "pagination.html" with list=model_switch_list %}
{% endif %} {% 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 %}"> <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> <i class="glyphicon glyphicon-time"></i>
</a> </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 %}"> <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> <i class="glyphicon glyphicon-edit"></i>
</a> </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 %}"> <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> <i class="glyphicon glyphicon-trash"></i>
</a> </a>
{% endif %} {% acl_end %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load acl %}
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <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 %}"> <a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'port' port.pk %}">
<i class="glyphicon glyphicon-time"></i> <i class="glyphicon glyphicon-time"></i>
</a> </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 %}"> <a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-port' port.id %}">
<i class="glyphicon glyphicon-edit"></i> <i class="glyphicon glyphicon-edit"></i>
</a> </a>
{% acl_end %}
{% can_delete port %}
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-port' port.pk %}"> <a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-port' port.pk %}">
<i class="glyphicon glyphicon-trash"></i> <i class="glyphicon glyphicon-trash"></i>
</a> </a>
{% endif %} {% acl_end %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load acl %}
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <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 %}"> <a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'stack' stack.pk %}">
<i class="glyphicon glyphicon-time"></i> <i class="glyphicon glyphicon-time"></i>
</a> </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 %}"> <a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-stack' stack.id %}">
<i class="glyphicon glyphicon-edit"></i> <i class="glyphicon glyphicon-edit"></i>
</a> </a>
{% acl_end %}
{% can_delete stack %}
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}"> <a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}">
<i class="glyphicon glyphicon-trash"></i> <i class="glyphicon glyphicon-trash"></i>
</a> </a>
{% endif %} {% acl_end %}
</td> </td>
{% endif %} {% endif %}
</tr> </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 %}"> <a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'stack' stack.pk %}">
<i class="glyphicon glyphicon-time"></i> <i class="glyphicon glyphicon-time"></i>
</a> </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 %}"> <a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-stack' stack.id %}">
<i class="glyphicon glyphicon-edit"></i> <i class="glyphicon glyphicon-edit"></i>
</a> </a>
{% acl_end %}
{% can_delete stack %}
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}"> <a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}">
<i class="glyphicon glyphicon-trash"></i> <i class="glyphicon glyphicon-trash"></i>
</a> </a>
{% endif %} {% acl_end %}
</td> </td>
{% endfor %} {% endfor %}
</tbody> </tbody>

View file

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load acl %}
{% if switch_list.paginator %} {% if switch_list.paginator %}
{% include "pagination.html" with list=switch_list %} {% include "pagination.html" with list=switch_list %}
{% endif %} {% endif %}
@ -56,11 +58,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{switch.details}}</td> <td>{{switch.details}}</td>
<td class="text-right"> <td class="text-right">
{% include 'buttons/history.html' with href='topologie:history' name='switch' id=switch.pk%} {% include 'buttons/history.html' with href='topologie:history' name='switch' id=switch.pk%}
{% if is_infra %} {% can_edit switch %}
{% include 'buttons/edit.html' with href='topologie:edit-switch' id=switch.pk %} {% 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 %} {% 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'%} {% include 'buttons/add.html' with href='topologie:create-ports' id=switch.pk desc='Création de ports'%}
{% endif %} {% acl_end %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load acl %}
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <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 %}"> <a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'stack' stack.pk %}">
<i class="glyphicon glyphicon-time"></i> <i class="glyphicon glyphicon-time"></i>
</a> </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 %}"> <a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-stack' stack.id %}">
<i class="glyphicon glyphicon-edit"></i> <i class="glyphicon glyphicon-edit"></i>
</a> </a>
{% acl_end %}
{% can_delete stack %}
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}"> <a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'topologie:del-stack' stack.pk %}">
<i class="glyphicon glyphicon-trash"></i> <i class="glyphicon glyphicon-trash"></i>
</a> </a>
{% endif %} {% acl_end %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -24,15 +24,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load acl %}
{% block title %}Switchs{% endblock %} {% block title %}Switchs{% endblock %}
{% block content %} {% block content %}
<h2>Switchs</h2> <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> <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> <hr>
{% endif %} {% acl_end %}
{% include "topologie/aff_switch.html" with switch_list=switch_list %} {% include "topologie/aff_switch.html" with switch_list=switch_list %}
<br /> <br />
<br /> <br />

View file

@ -24,21 +24,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load acl %}
{% block title %}Modèles de switches{% endblock %} {% block title %}Modèles de switches{% endblock %}
{% block content %} {% block content %}
<h2>Modèles de switches</h2> <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> <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> <hr>
{% endif %} {% acl_end %}
{% include "topologie/aff_model_switch.html" with model_switch_list=model_switch_list %} {% include "topologie/aff_model_switch.html" with model_switch_list=model_switch_list %}
<h2>Constructeurs de switches</h2> <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> <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> <hr>
{% endif %} {% acl_end %}
{% include "topologie/aff_constructor_switch.html" with constructor_switch_list=constructor_switch_list %} {% include "topologie/aff_constructor_switch.html" with constructor_switch_list=constructor_switch_list %}
<br /> <br />
<br /> <br />

View file

@ -24,16 +24,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load acl %}
{% block title %}Ports du switch{% endblock %} {% block title %}Ports du switch{% endblock %}
{% block content %} {% block content %}
<h2>Switch {{ nom_switch }}</h2> <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> <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> <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> <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 %} {% include "topologie/aff_port.html" with port_list=port_list %}
<br /> <br />
<br /> <br />

View file

@ -24,15 +24,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load acl %}
{% block title %}Chambres{% endblock %} {% block title %}Chambres{% endblock %}
{% block content %} {% block content %}
<h2>Chambres</h2> <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> <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> <hr>
{% endif %} {% acl_end %}
{% include "topologie/aff_chambres.html" with room_list=room_list %} {% include "topologie/aff_chambres.html" with room_list=room_list %}
<br /> <br />
<br /> <br />

View file

@ -24,14 +24,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load acl %}
{% block title %}Stacks{% endblock %} {% block title %}Stacks{% endblock %}
{% block content %} {% block content %}
<h2>Stacks</h2> <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> <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 %} {% include "topologie/aff_stacks.html" with stack_list=stack_list %}
<br /> <br />
<br /> <br />

View file

@ -70,7 +70,8 @@ from re2o.utils import (
can_create, can_create,
can_edit, can_edit,
can_delete, can_delete,
can_view can_view,
can_view_all,
) )
from machines.forms import ( from machines.forms import (
DomainForm, DomainForm,
@ -84,7 +85,7 @@ from preferences.models import AssoOption, GeneralOption
@login_required @login_required
@permission_required('cableur') @can_view_all(Switch)
def index(request): def index(request):
""" Vue d'affichage de tous les swicthes""" """ Vue d'affichage de tous les swicthes"""
switch_list = Switch.objects\ switch_list = Switch.objects\
@ -178,14 +179,10 @@ def history(request, object_name, object_id):
@login_required @login_required
@permission_required('cableur') @can_view_all(Port)
def index_port(request, switch_id): @can_view(Switch)
def index_port(request, switch, switch_id):
""" Affichage de l'ensemble des ports reliés à un switch particulier""" """ 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)\ port_list = Port.objects.filter(switch=switch)\
.select_related('room')\ .select_related('room')\
.select_related('machine_interface__domain__extension')\ .select_related('machine_interface__domain__extension')\
@ -208,7 +205,7 @@ def index_port(request, switch_id):
@login_required @login_required
@permission_required('cableur') @can_view_all(Room)
def index_room(request): def index_room(request):
""" Affichage de l'ensemble des chambres""" """ Affichage de l'ensemble des chambres"""
room_list = Room.objects room_list = Room.objects
@ -236,7 +233,7 @@ def index_room(request):
@login_required @login_required
@permission_required('infra') @can_view_all(Stack)
def index_stack(request): def index_stack(request):
"""Affichage de la liste des stacks (affiche l'ensemble des switches)""" """Affichage de la liste des stacks (affiche l'ensemble des switches)"""
stack_list = Stack.objects\ stack_list = Stack.objects\
@ -253,7 +250,8 @@ def index_stack(request):
@login_required @login_required
@permission_required('cableur') @can_view_all(ModelSwitch)
@can_view_all(ConstructorSwitch)
def index_model_switch(request): def index_model_switch(request):
""" Affichage de l'ensemble des modèles de switches""" """ Affichage de l'ensemble des modèles de switches"""
model_switch_list = ModelSwitch.objects model_switch_list = ModelSwitch.objects