8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-30 00:22:25 +00:00

Nouveau système d'acl dans les templates machines

This commit is contained in:
Gabriel Detraz 2017-12-28 00:05:31 +01:00 committed by root
parent 08ac168619
commit 397d2bbf20
22 changed files with 245 additions and 3 deletions

View file

@ -1367,7 +1367,7 @@ class Domain(models.Model):
:return: soit True, soit False avec la raison de l'échec"""
if not user_request.has_perms(('cableur',)) and\
self.get_source_interface.machine.user != user_request:
return False, u"Vous ne pouvez pas ajouter un alias à une machine\
return False, u"Vous ne pouvez pas editer un alias à une machine\
d'un autre user que vous sans droit"
return True, None

View file

@ -0,0 +1,139 @@
{% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
se veut agnostique au réseau considéré, de manière à être installable en
quelques clics.
Copyright © 2017 Gabriel Détraz
Copyright © 2017 Goulven Kermarec
Copyright © 2017 Augustin Lemesle
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
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 machines_list.paginator %}
{% include "pagination.html" with list=machines_list %}
{% endif %}
<table class="table">
<colgroup>
<col>
<col>
<col>
<col width="{% if ipv6_enabled %}300{% else %}150{% endif %}px">
<col width="144px">
</colgroup>
<thead>
<th>{% include "buttons/sort.html" with prefix='machine' col='name' text='Nom DNS' %}</th>
<th>Type</th>
<th>MAC</th>
<th>IP</th>
<th>Actions</th>
<tbody>
{% for machine in machines_list %}
<tr class="info">
<td colspan="4">
<b>{{ machine.name|default:'<i>Pas de nom</i>' }}</b> <i class="glyphicon glyphicon-chevron-right"></i>
<a href="{% url 'users:profil' userid=machine.user.id %}" title="Voir le profil">
<i class="glyphicon glyphicon-user"></i> {{ machine.user }}
</a>
</td>
<td class="text-right">
{% can_create Machine %}
{% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc='Ajouter une interface' %}
{% acl_end %}
{% can_edit machine %}
{% include 'buttons/history.html' with href='machines:history' name='machine' id=machine.id %}
{% acl_end %}
{% can_delete machine %}
{% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %}
{% acl_end %}
</td>
</tr>
{% for interface in machine.interface_set.all %}
<tr>
<td>
{% if interface.domain.related_domain.all %}
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="editioninterface" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{ interface.domain }} <span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="editioninterface">
{% for al in interface.domain.related_domain.all %}
<li>
<a href="http://{{ al }}">
{{ al }}
<i class="glyphicon glyphicon-share-alt"></i>
</a>
</li>
{% endfor %}
</ul>
</div>
{% else %}
{{ interface.domain }}
{% endif %}
</td>
<td>
{{ interface.type }}
</td>
<td>
{{ interface.mac_address }}
</td>
<td>
<b>IPv4</b> {{ interface.ipv4 }}
<br>
{% if ipv6_enabled and interface.ipv6 != 'None'%}
<b>IPv6</b> {{ interface.ipv6 }}
{% endif %}
</td>
<td class="text-right">
<div class="dropdown" style="width: 128px;">
<button class="btn btn-primary btn-sm dropdown-toggle" type="button" id="editioninterface" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="glyphicon glyphicon-edit"></i> <span class="caret"></span>
</button>
{% include 'buttons/history.html' with href='machines:history' name='interface' id=interface.id %}
{% include 'buttons/suppr.html' with href='machines:del-interface' id=interface.id %}
<ul class="dropdown-menu" aria-labelledby="editioninterface">
<li>
<a href="{% url 'machines:edit-interface' interface.id %}">
<i class="glyphicon glyphicon-edit"></i> Editer
</a>
</li>
<li>
<a href="{% url 'machines:index-alias' interface.id %}">
<i class="glyphicon glyphicon-edit"></i> Gerer les alias
</a>
</li>
<li>
<a href="{% url 'machines:port-config' interface.id%}">
<i class="glyphicon glyphicon-edit"></i> Gerer la configuration des ports
</a>
</li>
</ul>
</div>
</td>
</tr>
{% endfor %}
<tr>
<td colspan="8"></td>
</tr>
{% endfor %}
</tbody>
</table>
{% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %}
{% endif %}

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -33,7 +35,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<td>{{ alias }}</td>
<td class="text-right">
{% can_edit alias %}
{% include 'buttons/edit.html' with href='machines:edit-alias' id=alias.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='alias' id=alias.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -45,7 +47,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ extension.origin_v6 }}</td>
{% endif %}
<td class="text-right">
{% can_create Extension %}
{% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='extension' id=extension.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -48,7 +50,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ type.vlan }}</td>
<td>{{ type.ouverture_ports }}</td>
<td class="text-right">
{% can_edit type %}
{% include 'buttons/edit.html' with href='machines:edit-iptype' id=type.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='iptype' id=type.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
{% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %}
{% endif %}
@ -50,9 +52,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</a>
</td>
<td class="text-right">
{% can_create Interface machine.id %}
{% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc='Ajouter une interface' %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='machine' id=machine.id %}
{% can_delete machine %}
{% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %}
{% acl_end %}
</td>
</tr>
{% for interface in machine.interface_set.all %}
@ -97,23 +103,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="glyphicon glyphicon-edit"></i> <span class="caret"></span>
</button>
{% include 'buttons/history.html' with href='machines:history' name='interface' id=interface.id %}
{% can_delete interface %}
{% include 'buttons/suppr.html' with href='machines:del-interface' id=interface.id %}
<ul class="dropdown-menu" aria-labelledby="editioninterface">
<li>
{% acl_end %}
<ul class="dropdown-menu" aria-labelledby="editioninterface">
{% can_edit interface %}
<li>
<a href="{% url 'machines:edit-interface' interface.id %}">
<i class="glyphicon glyphicon-edit"></i> Editer
</a>
</li>
{% acl_end %}
{% can_create Domain interface.id %}
<li>
<a href="{% url 'machines:index-alias' interface.id %}">
<i class="glyphicon glyphicon-edit"></i> Gerer les alias
</a>
</li>
{% acl_end %}
{% can_create OuverturePortList %}
<li>
<a href="{% url 'machines:port-config' interface.id%}">
<i class="glyphicon glyphicon-edit"></i> Gerer la configuration des ports
</a>
</li>
{% acl_end %}
</ul>
</div>
</td>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -35,7 +37,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ type.type }}</td>
<td>{{ type.ip_type }}</td>
<td class="text-right">
{% can_edit type %}
{% include 'buttons/edit.html' with href='machines:edit-machinetype' id=type.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='machinetype' id=type.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -38,7 +40,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ mx.priority }}</td>
<td>{{ mx.name }}</td>
<td class="text-right">
{% can_edit mx %}
{% include 'buttons/edit.html' with href='machines:edit-mx' id=mx.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='mx' id=mx.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -41,7 +43,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ nas.port_access_mode }}</td>
<td>{{ nas.autocapture_mac }}</td>
<td class="text-right">
{% can_edit nas %}
{% include 'buttons/edit.html' with href='machines:edit-nas' id=nas.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='nas' id=nas.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -36,7 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ ns.zone }}</td>
<td>{{ ns.ns }}</td>
<td class="text-right">
{% can_edit ns %}
{% include 'buttons/edit.html' with href='machines:edit-ns' id=ns.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='ns' id=ns.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -40,7 +42,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ service.regular_time_regen }}</td>
<td>{% for serv in service.servers.all %}{{ serv }}, {% endfor %}</td>
<td class="text-right">
{% can_edit service %}
{% include 'buttons/edit.html' with href='machines:edit-service' id=service.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='service' id=service.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -44,7 +46,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ soa.expire }}</td>
<td>{{ soa.ttl }}</td>
<td class="text-right">
{% can_edit soa %}
{% include 'buttons/edit.html' with href='machines:edit-soa' id=soa.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='soa' id=soa.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -48,7 +50,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ srv.port }}</td>
<td>{{ srv.target }}</td>
<td class="text-right">
{% can_edit srv %}
{% include 'buttons/edit.html' with href='machines:edit-srv' id=srv.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='srv' id=srv.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -36,7 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ txt.zone }}</td>
<td>{{ txt.dns_entry }}</td>
<td class="text-right">
{% can_edit txt %}
{% include 'buttons/edit.html' with href='machines:edit-txt' id=txt.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='txt' id=txt.id %}
</td>
</tr>

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.
{% endcomment %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -39,7 +41,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ vlan.comment }}</td>
<td>{% for range in vlan.iptype_set.all %}{{ range }}, {% endfor%}</td>
<td class="text-right">
{% can_create Vlan %}
{% include 'buttons/edit.html' with href='machines:edit-vlan' id=vlan.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='machines:history' name='vlan' id=vlan.id %}
</td>
</tr>

View file

@ -25,32 +25,46 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% block title %}Machines{% endblock %}
{% block content %}
<h2>Liste des extensions</h2>
{% can_create Extension %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-extension' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une extension</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-extension' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer une ou plusieurs extensions</a>
{% include "machines/aff_extension.html" with extension_list=extension_list %}
<h2>Liste des enregistrements SOA</h2>
{% can_create SOA %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-soa' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un enregistrement SOA</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-soa' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement SOA</a>
{% include "machines/aff_soa.html" with soa_list=soa_list %}
<h2>Liste des enregistrements MX</h2>
{% can_create Mx %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-mx' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un enregistrement MX</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-mx' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement MX</a>
{% include "machines/aff_mx.html" with mx_list=mx_list %}
<h2>Liste des enregistrements NS</h2>
{% can_create Ns %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-ns' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un enregistrement NS</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-ns' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement NS</a>
{% include "machines/aff_ns.html" with ns_list=ns_list %}
<h2>Liste des enregistrements TXT</h2>
{% can_create Txt %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-txt' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un enregistrement TXT</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-txt' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement TXT</a>
{% include "machines/aff_txt.html" with txt_list=txt_list %}
<h2>Liste des enregistrements SRV</h2>
{% can_create Srv %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-srv' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un enregistrement SRV</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-srv' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement SRV</a>
{% include "machines/aff_srv.html" with srv_list=srv_list %}
<br />

View file

@ -25,11 +25,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% block title %}Ip{% endblock %}
{% block content %}
<h2>Liste des types d'ip</h2>
{% can_create IpType %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-iptype' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un type d'ip</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-iptype' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types d'ip</a>
{% include "machines/aff_iptype.html" with iptype_list=iptype_list %}
<br />

View file

@ -25,11 +25,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% block title %}Machines{% endblock %}
{% block content %}
<h2>Liste des types de machines</h2>
{% can_create MachineType %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-machinetype' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un type de machine</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-machinetype' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types de machines</a>
{% include "machines/aff_machinetype.html" with machinetype_list=machinetype_list %}
<br />

View file

@ -25,13 +25,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% block title %}Machines{% endblock %}
{% block content %}
<h2>Liste des nas</h2>
<h5>La correpondance nas-machinetype relie le type de nas à un type de machine.
Elle est utile pour l'autoenregistrement des macs par radius, et permet de choisir le type de machine à affecter aux machines en fonction du type de nas</h5>
{% can_create Nas %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-nas' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un type de nas</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-nas' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types nas</a>
{% include "machines/aff_nas.html" with nas_list=nas_list %}
<br />

View file

@ -2,11 +2,15 @@
{% load bootstrap3 %}
{% load acl %}
{% block title %}Configuration de ports{% endblock %}
{% block content %}
<h2>Liste des configurations de ports</h2>
{% can_create OuverturePortList %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-portlist' %}"><i class="glyphicon glyphicon-plus"></i>Ajouter une configuration</a>
{% acl_end %}
<table class="table table-striped">
<thead>
<tr>
@ -44,8 +48,12 @@
</div>
{% endif %}
<td class="text-right">
{% can_delete pl %}
{% include 'buttons/suppr.html' with href='machines:del-portlist' id=pl.id %}
{% acl_end %}
{% can_edit pl %}
{% include 'buttons/edit.html' with href='machines:edit-portlist' id=pl.id %}
{% acl_end %}
</td>
</tr>
{%endfor%}

View file

@ -24,12 +24,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load bootstrap3 %}
{% load acl %}
{% block title %}Machines{% endblock %}
{% block content %}
<h2>Liste des services</h2>
{% can_create Service %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-service' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un service</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-service' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs service</a>
{% include "machines/aff_service.html" with service_list=service_list %}
<h2>Etat des serveurs</h2>

View file

@ -25,11 +25,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% block title %}Machines{% endblock %}
{% block content %}
<h2>Liste des vlans</h2>
{% can_create Vlan %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-vlan' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un vlan</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-vlan' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs vlan</a>
{% include "machines/aff_vlan.html" with vlan_list=vlan_list %}
<br />