From 397d2bbf20d82b58d6a77b5820d4dbb52b5b9d1b Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 28 Dec 2017 00:05:31 +0100 Subject: [PATCH] =?UTF-8?q?Nouveau=20syst=C3=A8me=20d'acl=20dans=20les=20t?= =?UTF-8?q?emplates=20machines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/models.py | 2 +- machines/templates/machines/:w | 139 ++++++++++++++++++ machines/templates/machines/aff_alias.html | 4 + .../templates/machines/aff_extension.html | 4 + machines/templates/machines/aff_iptype.html | 4 + machines/templates/machines/aff_machines.html | 18 ++- .../templates/machines/aff_machinetype.html | 4 + machines/templates/machines/aff_mx.html | 4 + machines/templates/machines/aff_nas.html | 4 + machines/templates/machines/aff_ns.html | 4 + machines/templates/machines/aff_service.html | 4 + machines/templates/machines/aff_soa.html | 4 + machines/templates/machines/aff_srv.html | 4 + machines/templates/machines/aff_txt.html | 4 + machines/templates/machines/aff_vlan.html | 4 + .../templates/machines/index_extension.html | 14 ++ machines/templates/machines/index_iptype.html | 4 + .../templates/machines/index_machinetype.html | 4 + machines/templates/machines/index_nas.html | 4 + .../templates/machines/index_portlist.html | 8 + .../templates/machines/index_service.html | 3 + machines/templates/machines/index_vlan.html | 4 + 22 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 machines/templates/machines/:w diff --git a/machines/models.py b/machines/models.py index f2118e84..ab17217b 100644 --- a/machines/models.py +++ b/machines/models.py @@ -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 diff --git a/machines/templates/machines/:w b/machines/templates/machines/:w new file mode 100644 index 00000000..9d405a79 --- /dev/null +++ b/machines/templates/machines/:w @@ -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 %} + + + + + + + + + + + + + + + + + {% for machine in machines_list %} + + + + + {% for interface in machine.interface_set.all %} + + + + + + + + {% endfor %} + + + + {% endfor %} + +
{% include "buttons/sort.html" with prefix='machine' col='name' text='Nom DNS' %}TypeMACIPActions
+ {{ machine.name|default:'Pas de nom' }} + + {{ machine.user }} + + + {% 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 %} +
+ {% if interface.domain.related_domain.all %} + + {% else %} + {{ interface.domain }} + {% endif %} + + {{ interface.type }} + + {{ interface.mac_address }} + + IPv4 {{ interface.ipv4 }} +
+ {% if ipv6_enabled and interface.ipv6 != 'None'%} + IPv6 {{ interface.ipv6 }} + {% endif %} +
+ +
+ +{% if machines_list.paginator %} +{% include "pagination.html" with list=machines_list %} +{% endif %} diff --git a/machines/templates/machines/aff_alias.html b/machines/templates/machines/aff_alias.html index bd64c737..fb3f0486 100644 --- a/machines/templates/machines/aff_alias.html +++ b/machines/templates/machines/aff_alias.html @@ -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 %} + @@ -33,7 +35,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_extension.html b/machines/templates/machines/aff_extension.html index d2fca481..0da5a08e 100644 --- a/machines/templates/machines/aff_extension.html +++ b/machines/templates/machines/aff_extension.html @@ -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 %} +
{{ alias }} + {% 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 %}
@@ -45,7 +47,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endif %} diff --git a/machines/templates/machines/aff_iptype.html b/machines/templates/machines/aff_iptype.html index dc50cd4c..c5ed4c10 100644 --- a/machines/templates/machines/aff_iptype.html +++ b/machines/templates/machines/aff_iptype.html @@ -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 %} +
{{ extension.origin_v6 }} + {% 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 %}
@@ -48,7 +50,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index 63d35241..ab03d79a 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -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., {% for interface in machine.interface_set.all %} @@ -97,23 +103,31 @@ with this program; if not, write to the Free Software Foundation, Inc., {% 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 %} -
{{ type.vlan }} {{ type.ouverture_ports }} + {% 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 %}
+ {% 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 %}
@@ -35,7 +37,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_mx.html b/machines/templates/machines/aff_mx.html index 8c27bbfd..4478cdab 100644 --- a/machines/templates/machines/aff_mx.html +++ b/machines/templates/machines/aff_mx.html @@ -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 %} +
{{ type.type }} {{ type.ip_type }} + {% 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 %}
@@ -38,7 +40,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_nas.html b/machines/templates/machines/aff_nas.html index 670ef893..735a4ca8 100644 --- a/machines/templates/machines/aff_nas.html +++ b/machines/templates/machines/aff_nas.html @@ -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 %} +
{{ mx.priority }} {{ mx.name }} + {% 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 %}
@@ -41,7 +43,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_ns.html b/machines/templates/machines/aff_ns.html index d1157c52..5ee87304 100644 --- a/machines/templates/machines/aff_ns.html +++ b/machines/templates/machines/aff_ns.html @@ -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 %} +
{{ nas.port_access_mode }} {{ nas.autocapture_mac }} + {% 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 %}
@@ -36,7 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_service.html b/machines/templates/machines/aff_service.html index e8a228da..da80b4da 100644 --- a/machines/templates/machines/aff_service.html +++ b/machines/templates/machines/aff_service.html @@ -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 %} +
{{ ns.zone }} {{ ns.ns }} + {% 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 %}
@@ -40,7 +42,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_soa.html b/machines/templates/machines/aff_soa.html index 3386ed2d..5352a739 100644 --- a/machines/templates/machines/aff_soa.html +++ b/machines/templates/machines/aff_soa.html @@ -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 %} +
{{ service.regular_time_regen }} {% for serv in service.servers.all %}{{ serv }}, {% endfor %} + {% 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 %}
@@ -44,7 +46,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_srv.html b/machines/templates/machines/aff_srv.html index 039df718..e7886cf1 100644 --- a/machines/templates/machines/aff_srv.html +++ b/machines/templates/machines/aff_srv.html @@ -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 %} +
{{ soa.expire }} {{ soa.ttl }} + {% 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 %}
@@ -48,7 +50,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_txt.html b/machines/templates/machines/aff_txt.html index 053cb239..973fd6d9 100644 --- a/machines/templates/machines/aff_txt.html +++ b/machines/templates/machines/aff_txt.html @@ -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 %} +
{{ srv.port }} {{ srv.target }} + {% 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 %}
@@ -36,7 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/aff_vlan.html b/machines/templates/machines/aff_vlan.html index 3245d877..deb8cb11 100644 --- a/machines/templates/machines/aff_vlan.html +++ b/machines/templates/machines/aff_vlan.html @@ -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 %} +
{{ txt.zone }} {{ txt.dns_entry }} + {% 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 %}
@@ -39,7 +41,9 @@ with this program; if not, write to the Free Software Foundation, Inc., diff --git a/machines/templates/machines/index_extension.html b/machines/templates/machines/index_extension.html index 5f8d1bd2..a0159974 100644 --- a/machines/templates/machines/index_extension.html +++ b/machines/templates/machines/index_extension.html @@ -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 %}

Liste des extensions

+ {% can_create Extension %} Ajouter une extension + {% acl_end %} Supprimer une ou plusieurs extensions {% include "machines/aff_extension.html" with extension_list=extension_list %}

Liste des enregistrements SOA

+ {% can_create SOA %} Ajouter un enregistrement SOA + {% acl_end %} Supprimer un enregistrement SOA {% include "machines/aff_soa.html" with soa_list=soa_list %}

Liste des enregistrements MX

+ {% can_create Mx %} Ajouter un enregistrement MX + {% acl_end %} Supprimer un enregistrement MX {% include "machines/aff_mx.html" with mx_list=mx_list %}

Liste des enregistrements NS

+ {% can_create Ns %} Ajouter un enregistrement NS + {% acl_end %} Supprimer un enregistrement NS {% include "machines/aff_ns.html" with ns_list=ns_list %}

Liste des enregistrements TXT

+ {% can_create Txt %} Ajouter un enregistrement TXT + {% acl_end %} Supprimer un enregistrement TXT {% include "machines/aff_txt.html" with txt_list=txt_list %}

Liste des enregistrements SRV

+ {% can_create Srv %} Ajouter un enregistrement SRV + {% acl_end %} Supprimer un enregistrement SRV {% include "machines/aff_srv.html" with srv_list=srv_list %}
diff --git a/machines/templates/machines/index_iptype.html b/machines/templates/machines/index_iptype.html index 10bb2079..cd582183 100644 --- a/machines/templates/machines/index_iptype.html +++ b/machines/templates/machines/index_iptype.html @@ -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 %}

Liste des types d'ip

+ {% can_create IpType %} Ajouter un type d'ip + {% acl_end %} Supprimer un ou plusieurs types d'ip {% include "machines/aff_iptype.html" with iptype_list=iptype_list %}
diff --git a/machines/templates/machines/index_machinetype.html b/machines/templates/machines/index_machinetype.html index 75399aba..96fa2d7e 100644 --- a/machines/templates/machines/index_machinetype.html +++ b/machines/templates/machines/index_machinetype.html @@ -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 %}

Liste des types de machines

+ {% can_create MachineType %} Ajouter un type de machine + {% acl_end %} Supprimer un ou plusieurs types de machines {% include "machines/aff_machinetype.html" with machinetype_list=machinetype_list %}
diff --git a/machines/templates/machines/index_nas.html b/machines/templates/machines/index_nas.html index 16fb29e2..b4f99ac4 100644 --- a/machines/templates/machines/index_nas.html +++ b/machines/templates/machines/index_nas.html @@ -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 %}

Liste des nas

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
+ {% can_create Nas %} Ajouter un type de nas + {% acl_end %} Supprimer un ou plusieurs types nas {% include "machines/aff_nas.html" with nas_list=nas_list %}
diff --git a/machines/templates/machines/index_portlist.html b/machines/templates/machines/index_portlist.html index 04ac66d4..5c0c148a 100644 --- a/machines/templates/machines/index_portlist.html +++ b/machines/templates/machines/index_portlist.html @@ -2,11 +2,15 @@ {% load bootstrap3 %} +{% load acl %} + {% block title %}Configuration de ports{% endblock %} {% block content %}

Liste des configurations de ports

+ {% can_create OuverturePortList %} Ajouter une configuration + {% acl_end %}
{{ vlan.comment }} {% for range in vlan.iptype_set.all %}{{ range }}, {% endfor%} + {% 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 %}
@@ -44,8 +48,12 @@ {% endif %} {%endfor%} diff --git a/machines/templates/machines/index_service.html b/machines/templates/machines/index_service.html index 1fa917f3..4a06761d 100644 --- a/machines/templates/machines/index_service.html +++ b/machines/templates/machines/index_service.html @@ -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 %}

Liste des services

+ {% can_create Service %} Ajouter un service + {% acl_end %} Supprimer un ou plusieurs service {% include "machines/aff_service.html" with service_list=service_list %}

Etat des serveurs

diff --git a/machines/templates/machines/index_vlan.html b/machines/templates/machines/index_vlan.html index ccbfa753..d9a4f8f9 100644 --- a/machines/templates/machines/index_vlan.html +++ b/machines/templates/machines/index_vlan.html @@ -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 %}

Liste des vlans

+ {% can_create Vlan %} Ajouter un vlan + {% acl_end %} Supprimer un ou plusieurs vlan {% include "machines/aff_vlan.html" with vlan_list=vlan_list %}
+ {% 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 %}