From 1e9a4b3d324bcc3cb00e19c90fe08b21c29c675e Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 24 Sep 2018 19:31:12 +0200 Subject: [PATCH 1/2] Autoformat templates --- machines/templates/machines/aff_alias.html | 11 +- machines/templates/machines/aff_dname.html | 13 +- .../templates/machines/aff_extension.html | 49 ++-- machines/templates/machines/aff_iptype.html | 56 ++--- machines/templates/machines/aff_ipv6.html | 17 +- machines/templates/machines/aff_machines.html | 206 ++++++++--------- .../templates/machines/aff_machinetype.html | 13 +- machines/templates/machines/aff_mx.html | 15 +- machines/templates/machines/aff_nas.html | 21 +- machines/templates/machines/aff_ns.html | 13 +- machines/templates/machines/aff_role.html | 27 ++- machines/templates/machines/aff_servers.html | 15 +- machines/templates/machines/aff_service.html | 22 +- machines/templates/machines/aff_soa.html | 21 +- machines/templates/machines/aff_srv.html | 25 +- machines/templates/machines/aff_sshfp.html | 17 +- machines/templates/machines/aff_txt.html | 13 +- machines/templates/machines/aff_vlan.html | 21 +- machines/templates/machines/delete.html | 20 +- .../templates/machines/edit_portlist.html | 73 +++--- machines/templates/machines/index.html | 11 +- machines/templates/machines/index_alias.html | 15 +- .../templates/machines/index_extension.html | 123 +++++----- machines/templates/machines/index_iptype.html | 21 +- machines/templates/machines/index_ipv6.html | 19 +- .../templates/machines/index_machinetype.html | 23 +- machines/templates/machines/index_nas.html | 25 +- .../templates/machines/index_portlist.html | 110 +++++---- machines/templates/machines/index_role.html | 17 +- .../templates/machines/index_service.html | 23 +- machines/templates/machines/index_sshfp.html | 3 +- machines/templates/machines/index_vlan.html | 19 +- machines/templates/machines/machine.html | 214 +++++++++--------- machines/templates/machines/sidebar.html | 15 +- 34 files changed, 654 insertions(+), 652 deletions(-) diff --git a/machines/templates/machines/aff_alias.html b/machines/templates/machines/aff_alias.html index 17266a6e..5a1bc8f8 100644 --- a/machines/templates/machines/aff_alias.html +++ b/machines/templates/machines/aff_alias.html @@ -28,21 +28,20 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - + + + + {% for alias in alias_list %} {% endfor %}
{% trans "Aliases" %}
{% trans "Aliases" %}
{{ alias }} {% can_edit alias %} - {% include 'buttons/edit.html' with href='machines:edit-alias' id=alias.id %} + {% include 'buttons/edit.html' with href='machines:edit-alias' id=alias.id %} {% acl_end %} {% history_button alias %}
- diff --git a/machines/templates/machines/aff_dname.html b/machines/templates/machines/aff_dname.html index 7e043d7c..66883057 100644 --- a/machines/templates/machines/aff_dname.html +++ b/machines/templates/machines/aff_dname.html @@ -26,11 +26,11 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - + + + + + {% for dname in dname_list %} @@ -38,11 +38,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Target zone" %}{% trans "Record" %}
{% trans "Target zone" %}{% trans "Record" %}
{{ dname.dns_entry }} {% can_edit dname %} - {% include 'buttons/edit.html' with href='machines:edit-dname' id=dname.id %} + {% include 'buttons/edit.html' with href='machines:edit-dname' id=dname.id %} {% acl_end %} {% history_button dname %}
- diff --git a/machines/templates/machines/aff_extension.html b/machines/templates/machines/aff_extension.html index 43bb9e39..b8493f5f 100644 --- a/machines/templates/machines/aff_extension.html +++ b/machines/templates/machines/aff_extension.html @@ -30,34 +30,33 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- - - - - - {% if ipv6_enabled %} + + + + + + {% if ipv6_enabled %} - {% endif %} - - + {% endif %} + + {% for extension in extension_list %} - - - - - - {% if ipv6_enabled %} - - {% endif %} - - + + + + + + {% if ipv6_enabled %} + + {% endif %} + + {% endfor %}
{% trans "Extension" %}{% trans "'infra' right required" %}{% trans "SOA record" %}{% trans "A record origin" %}
{% trans "Extension" %}{% trans "'infra' right required" %}{% trans "SOA record" %}{% trans "A record origin" %}{% trans "AAAA record origin" %}
{{ extension.name }}{{ extension.need_infra|tick }}{{ extension.soa }}{{ extension.origin }}{{ extension.origin_v6 }} - {% can_edit extension %} - {% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %} - {% acl_end %} - {% history_button extension %} -
{{ extension.name }}{{ extension.need_infra|tick }}{{ extension.soa }}{{ extension.origin }}{{ extension.origin_v6 }} + {% can_edit extension %} + {% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %} + {% acl_end %} + {% history_button extension %} +
- diff --git a/machines/templates/machines/aff_iptype.html b/machines/templates/machines/aff_iptype.html index b8ed5293..b408bfb1 100644 --- a/machines/templates/machines/aff_iptype.html +++ b/machines/templates/machines/aff_iptype.html @@ -31,36 +31,36 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- - - - - - - - - - - + + + + + + + + + + + {% for type in iptype_list %} - - - - - - - - - - - + + + + + + + + + + + {% endfor %}
{% trans "IP type" %}{% trans "Extension" %}{% trans "'infra' right required" %}{% trans "IPv4 range" %}{% trans "v6 prefix" %}{% trans "DNSSEC reverse v4/v6" %}{% trans "On VLAN(s)" %}{% trans "Default ports opening" %}
{% trans "IP type" %}{% trans "Extension" %}{% trans "'infra' right required" %}{% trans "IPv4 range" %}{% trans "v6 prefix" %}{% trans "DNSSEC reverse v4/v6" %}{% trans "On VLAN(s)" %}{% trans "Default ports opening" %}
{{ type.type }}{{ type.extension }}{{ type.need_infra|tick }}{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{% if type.ip_network %} on {{ type.ip_network }}{% endif %}{{ type.prefix_v6 }}/{{ type.prefix_v6_length }}{{ type.reverse_v4|tick }}/{{ type.reverse_v6|tick }}{{ type.vlan }}{{ type.ouverture_ports }} - {% can_edit type %} - {% include 'buttons/edit.html' with href='machines:edit-iptype' id=type.id %} - {% acl_end %} - {% history_button type %} -
{{ type.type }}{{ type.extension }}{{ type.need_infra|tick }}{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{% if type.ip_network %} on + {{ type.ip_network }}{% endif %}{{ type.prefix_v6 }}/{{ type.prefix_v6_length }}{{ type.reverse_v4|tick }}/{{ type.reverse_v6|tick }}{{ type.vlan }}{{ type.ouverture_ports }} + {% can_edit type %} + {% include 'buttons/edit.html' with href='machines:edit-iptype' id=type.id %} + {% acl_end %} + {% history_button type %} +
- diff --git a/machines/templates/machines/aff_ipv6.html b/machines/templates/machines/aff_ipv6.html index a98c0327..e8e4a48e 100644 --- a/machines/templates/machines/aff_ipv6.html +++ b/machines/templates/machines/aff_ipv6.html @@ -28,26 +28,25 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - + + + + + + {% for ipv6 in ipv6_list %} {% endfor %}
{% trans "IPv6 addresses" %}{% trans "SLAAC" %}
{% trans "IPv6 addresses" %}{% trans "SLAAC" %}
{{ ipv6.ipv6 }} {{ ipv6.slaac_ip }} {% can_edit ipv6 %} - {% include 'buttons/edit.html' with href='machines:edit-ipv6list' id=ipv6.id %} + {% include 'buttons/edit.html' with href='machines:edit-ipv6list' id=ipv6.id %} {% acl_end %} {% can_delete ipv6 %} - {% include 'buttons/suppr.html' with href='machines:del-ipv6list' id=ipv6.id %} + {% include 'buttons/suppr.html' with href='machines:del-ipv6list' id=ipv6.id %} {% acl_end %} {% history_button ipv6 %}
- diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index 76ba3451..bd65fc76 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if machines_list.paginator %} - {% include "pagination.html" with list=machines_list %} + {% include "pagination.html" with list=machines_list %} {% endif %} @@ -61,156 +61,160 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_create Interface machine.id %} {% trans "Create an interface" as tr_create_an_interface %} {% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc=tr_create_an_interface %} - {% acl_end %} - {% history_button machine %} - {% can_delete machine %} + {% acl_end %} + {% history_button machine %} + {% can_delete machine %} {% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %} - {% acl_end %} - - - {% for interface in machine.interface_set.all %} + {% acl_end %} + + + {% for interface in machine.interface_set.all %} + - {% if ipv6_enabled and interface.ipv6 != 'None'%} - - - + {% if ipv6_enabled and interface.ipv6 != 'None' %} + + + {% endif %} {% if interface.domain.related_domain.all %} - - - + + + {% endif %} - {% endfor %} - - - {% endfor %} - - + + + + {% endfor %} +
{% if interface.domain.related_domain.all %} - {{ interface.domain }} - + {{ interface.domain }} + {% else %} - {{ interface.domain }} + {{ interface.domain }} {% endif %} {{ interface.type }} - {{ interface.mac_address }} IPv4 {{ interface.ipv4 }}
- {% if ipv6_enabled and interface.ipv6 != 'None'%} - IPv6 - + {% if ipv6_enabled and interface.ipv6 != 'None' %} + IPv6 + {% endif %}
-
{% history_button interface %} {% can_delete interface %} - {% include 'buttons/suppr.html' with href='machines:del-interface' id=interface.id %} + {% include 'buttons/suppr.html' with href='machines:del-interface' id=interface.id %} {% acl_end %}
-
-
    - {% for ipv6 in interface.ipv6.all %} -
  • - {{ ipv6 }} -
  • - {% endfor %} -
-
-
+
+
    + {% for ipv6 in interface.ipv6.all %} +
  • + {{ ipv6 }} +
  • + {% endfor %} +
+
+
-
-
    - {% for al in interface.domain.related_domain.all %} -
  • - - {{ al }} - - -
  • - {% endfor %} -
-
-
+
+
    + {% for al in interface.domain.related_domain.all %} +
  • + + {{ al }} + + +
  • + {% endfor %} +
+
+
{% if machines_list.paginator %} - {% include "pagination.html" with list=machines_list %} + {% include "pagination.html" with list=machines_list %} {% endif %}
- diff --git a/machines/templates/machines/aff_machinetype.html b/machines/templates/machines/aff_machinetype.html index 4725ffb8..a55a5370 100644 --- a/machines/templates/machines/aff_machinetype.html +++ b/machines/templates/machines/aff_machinetype.html @@ -28,11 +28,11 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - + + + + + {% for type in machinetype_list %} @@ -40,11 +40,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Machine type" %}{% trans "Matching IP type" %}
{% trans "Machine type" %}{% trans "Matching IP type" %}
{{ type.ip_type }} {% can_edit type %} - {% include 'buttons/edit.html' with href='machines:edit-machinetype' id=type.id %} + {% include 'buttons/edit.html' with href='machines:edit-machinetype' id=type.id %} {% acl_end %} {% history_button type %}
- diff --git a/machines/templates/machines/aff_mx.html b/machines/templates/machines/aff_mx.html index e57e73a4..4a50724b 100644 --- a/machines/templates/machines/aff_mx.html +++ b/machines/templates/machines/aff_mx.html @@ -28,12 +28,12 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - + + + + + + {% for mx in mx_list %} @@ -42,11 +42,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Concerned zone" %}{% trans "Priority" %}{% trans "Record" %}
{% trans "Concerned zone" %}{% trans "Priority" %}{% trans "Record" %}
{{ mx.name }} {% can_edit mx %} - {% include 'buttons/edit.html' with href='machines:edit-mx' id=mx.id %} + {% include 'buttons/edit.html' with href='machines:edit-mx' id=mx.id %} {% acl_end %} {% history_button mx %}
- diff --git a/machines/templates/machines/aff_nas.html b/machines/templates/machines/aff_nas.html index 0dd612cc..84013f90 100644 --- a/machines/templates/machines/aff_nas.html +++ b/machines/templates/machines/aff_nas.html @@ -29,29 +29,28 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - - - + + + + + + + + {% for nas in nas_list %} - + {% endfor %}
{% trans "Name" %}{% trans "NAS device type" %}{% trans "Machine type linked to the NAS device" %}{% trans "Access mode" %}{% trans "MAC address auto capture" %}
{% trans "Name" %}{% trans "NAS device type" %}{% trans "Machine type linked to the NAS device" %}{% trans "Access mode" %}{% trans "MAC address auto capture" %}
{{ nas.name }}{{ nas.nas_type }}{{ nas.nas_type }} {{ nas.machine_type }} {{ nas.port_access_mode }} {{ nas.autocapture_mac|tick }} {% can_edit nas %} - {% include 'buttons/edit.html' with href='machines:edit-nas' id=nas.id %} + {% include 'buttons/edit.html' with href='machines:edit-nas' id=nas.id %} {% acl_end %} {% history_button nas %}
- diff --git a/machines/templates/machines/aff_ns.html b/machines/templates/machines/aff_ns.html index e2187e3e..2968607a 100644 --- a/machines/templates/machines/aff_ns.html +++ b/machines/templates/machines/aff_ns.html @@ -28,11 +28,11 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - + + + + + {% for ns in ns_list %} @@ -40,11 +40,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Concerned zone" %}{% trans "Authoritarian interface for the concerned zone" %}
{% trans "Concerned zone" %}{% trans "Authoritarian interface for the concerned zone" %}
{{ ns.ns }} {% can_edit ns %} - {% include 'buttons/edit.html' with href='machines:edit-ns' id=ns.id %} + {% include 'buttons/edit.html' with href='machines:edit-ns' id=ns.id %} {% acl_end %} {% history_button ns %}
- diff --git a/machines/templates/machines/aff_role.html b/machines/templates/machines/aff_role.html index bba094b3..b6303917 100644 --- a/machines/templates/machines/aff_role.html +++ b/machines/templates/machines/aff_role.html @@ -29,13 +29,13 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - - + + + + + + + {% for role in role_list %} @@ -43,12 +43,11 @@ with this program; if not, write to the Free Software Foundation, Inc., - + {% can_edit role %} + {% include 'buttons/edit.html' with href='machines:edit-role' id=role.id %} + {% acl_end %} + {% history_button role %} + + {% endfor %}
{% trans "Role name" %}{% trans "Specific role" %}{% trans "Servers" %}
{% trans "Role name" %}{% trans "Specific role" %}{% trans "Servers" %}
{{ role.specific_role }} {% for serv in role.servers.all %}{{ serv }}, {% endfor %} - {% can_edit role %} - {% include 'buttons/edit.html' with href='machines:edit-role' id=role.id %} - {% acl_end %} - {% history_button role %} -
- diff --git a/machines/templates/machines/aff_servers.html b/machines/templates/machines/aff_servers.html index 7dd25495..4134c269 100644 --- a/machines/templates/machines/aff_servers.html +++ b/machines/templates/machines/aff_servers.html @@ -27,13 +27,13 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - - + + + + + + + {% for server in servers_list %} @@ -47,4 +47,3 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Service name" %}{% trans "Server" %}{% trans "Last regeneration" %}{% trans "Regeneration required" %}{% trans "Regeneration activated" %}
{% trans "Service name" %}{% trans "Server" %}{% trans "Last regeneration" %}{% trans "Regeneration required" %}{% trans "Regeneration activated" %}
- diff --git a/machines/templates/machines/aff_service.html b/machines/templates/machines/aff_service.html index df04b93c..102ceead 100644 --- a/machines/templates/machines/aff_service.html +++ b/machines/templates/machines/aff_service.html @@ -28,14 +28,14 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - - - + + + + + + + + {% for service in service_list %} @@ -43,14 +43,14 @@ with this program; if not, write to the Free Software Foundation, Inc., - + {% endfor %}
{% trans "Service name" %}{% trans "Minimal time before regeneration" %}{% trans "Maximal time before regeneration" %}{% trans "Included servers" %}{% trans "Ask for regeneration" %}
{% trans "Service name" %}{% trans "Minimal time before regeneration" %}{% trans "Maximal time before regeneration" %}{% trans "Included servers" %}{% trans "Ask for regeneration" %}
{{ service.min_time_regen }} {{ 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 %} + {% include 'buttons/edit.html' with href='machines:edit-service' id=service.id %} {% acl_end %} {% history_button service %}
- diff --git a/machines/templates/machines/aff_soa.html b/machines/templates/machines/aff_soa.html index fbf206e0..9199533e 100644 --- a/machines/templates/machines/aff_soa.html +++ b/machines/templates/machines/aff_soa.html @@ -28,15 +28,15 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - - - - + + + + + + + + + {% for soa in soa_list %} @@ -48,11 +48,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Name" %}{% trans "Mail" %}{% trans "Refresh" %}{% trans "Retry" %}{% trans "Expire" %}{% trans "TTL" %}
{% trans "Name" %}{% trans "Mail" %}{% trans "Refresh" %}{% trans "Retry" %}{% trans "Expire" %}{% trans "TTL" %}
{{ soa.ttl }} {% can_edit soa %} - {% include 'buttons/edit.html' with href='machines:edit-soa' id=soa.id %} + {% include 'buttons/edit.html' with href='machines:edit-soa' id=soa.id %} {% acl_end %} {% history_button soa %}
- diff --git a/machines/templates/machines/aff_srv.html b/machines/templates/machines/aff_srv.html index 2ee569e0..71fb78a2 100644 --- a/machines/templates/machines/aff_srv.html +++ b/machines/templates/machines/aff_srv.html @@ -28,17 +28,17 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - - - - - - + + + + + + + + + + + {% for srv in srv_list %} @@ -52,11 +52,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Service" %}{% trans "Protocol" %}{% trans "Extension" %}{% trans "TTL" %}{% trans "Priority" %}{% trans "Weight" %}{% trans "Port" %}{% trans "Target" %}
{% trans "Service" %}{% trans "Protocol" %}{% trans "Extension" %}{% trans "TTL" %}{% trans "Priority" %}{% trans "Weight" %}{% trans "Port" %}{% trans "Target" %}
{{ srv.target }} {% can_edit srv %} - {% include 'buttons/edit.html' with href='machines:edit-srv' id=srv.id %} + {% include 'buttons/edit.html' with href='machines:edit-srv' id=srv.id %} {% acl_end %} {% history_button srv %}
- diff --git a/machines/templates/machines/aff_sshfp.html b/machines/templates/machines/aff_sshfp.html index f684d6a0..08d1df13 100644 --- a/machines/templates/machines/aff_sshfp.html +++ b/machines/templates/machines/aff_sshfp.html @@ -27,12 +27,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- - - - - - + + + + + + {% for sshfp in sshfp_list %} @@ -41,15 +41,14 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "SSH public key" %}{% trans "Algorithm used" %}{% trans "Comment" %}
{% trans "SSH public key" %}{% trans "Algorithm used" %}{% trans "Comment" %}
{{ sshfp.comment }} {% can_edit sshfp %} - {% include 'buttons/edit.html' with href='machines:edit-sshfp' id=sshfp.id %} + {% include 'buttons/edit.html' with href='machines:edit-sshfp' id=sshfp.id %} {% acl_end %} {% history_button sshfp %} {% can_delete sshfp %} - {% include 'buttons/suppr.html' with href='machines:del-sshfp' id=sshfp.id %} + {% include 'buttons/suppr.html' with href='machines:del-sshfp' id=sshfp.id %} {% acl_end %}
- diff --git a/machines/templates/machines/aff_txt.html b/machines/templates/machines/aff_txt.html index 41778cba..456f7343 100644 --- a/machines/templates/machines/aff_txt.html +++ b/machines/templates/machines/aff_txt.html @@ -28,11 +28,11 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - + + + + + {% for txt in txt_list %} @@ -40,11 +40,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "Concerned zone" %}{% trans "Record" %}
{% trans "Concerned zone" %}{% trans "Record" %}
{{ txt.dns_entry }} {% can_edit txt %} - {% include 'buttons/edit.html' with href='machines:edit-txt' id=txt.id %} + {% include 'buttons/edit.html' with href='machines:edit-txt' id=txt.id %} {% acl_end %} {% history_button txt %}
- diff --git a/machines/templates/machines/aff_vlan.html b/machines/templates/machines/aff_vlan.html index 0c1ed053..3ccbfcb0 100644 --- a/machines/templates/machines/aff_vlan.html +++ b/machines/templates/machines/aff_vlan.html @@ -29,23 +29,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- - - - - - - + + + + + + + {% for vlan in vlan_list %} - + - + @@ -53,4 +53,3 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
{% trans "ID" %}{% trans "Name" %}{% trans "Comment" %}{% trans "IP ranges" %}
{% trans "ID" %}{% trans "Name" %}{% trans "Comment" %}{% trans "IP ranges" %}
{{ vlan.vlan_id }}{{ vlan.name }}{{ vlan.name }} {{ vlan.comment }}{% for range in vlan.iptype_set.all %}{{ range }}, {% endfor%}{% for range in vlan.iptype_set.all %}{{ range }}, {% endfor %} {% can_edit vlan %} - {% include 'buttons/edit.html' with href='machines:edit-vlan' id=vlan.id %} + {% include 'buttons/edit.html' with href='machines:edit-vlan' id=vlan.id %} {% acl_end %} {% history_button vlan %}
- diff --git a/machines/templates/machines/delete.html b/machines/templates/machines/delete.html index ae365c69..f009f905 100644 --- a/machines/templates/machines/delete.html +++ b/machines/templates/machines/delete.html @@ -30,14 +30,14 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block content %} -
- {% csrf_token %} -

{% blocktrans %}Warning: are you sure you want to delete this object {{ objet_name }} ( {{ objet }} )?{% endblocktrans %}

- {% trans "Confirm" as tr_confirm %} - {% bootstrap_button tr_confirm button_type="submit" icon='trash' button_class='btn-danger' %} -
-
-
-
+
+ {% csrf_token %} +

{% blocktrans %}Warning: are you sure you want to delete this object {{ objet_name }} ( {{ objet }} + )?{% endblocktrans %}

+ {% trans "Confirm" as tr_confirm %} + {% bootstrap_button tr_confirm button_type="submit" icon='trash' button_class='btn-danger' %} +
+
+
+
{% endblock %} - diff --git a/machines/templates/machines/edit_portlist.html b/machines/templates/machines/edit_portlist.html index 5bb8723f..a7aa6f04 100644 --- a/machines/templates/machines/edit_portlist.html +++ b/machines/templates/machines/edit_portlist.html @@ -29,44 +29,45 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -{% bootstrap_form_errors port_list %} + {% bootstrap_form_errors port_list %} -
- {% csrf_token %} - {% bootstrap_form port_list %} - {{ ports.management_form }} -
- {% for form in ports.forms %} -
-

- {{ form }} -

-
- {% endfor %} -
+ + {% csrf_token %} + {% bootstrap_form port_list %} + {{ ports.management_form }} +
+ {% for form in ports.forms %} +
+

+ {{ form }} +

+
+ {% endfor %} +
-

- {% trans "Add a port" as value %} - -

- {% trans "Create or edit" as tr_create_or_edit %} - {% bootstrap_button tr_create_or_edit icon='ok' button_class='btn-success' %} -
- + function add_port() { + var new_index = document.getElementsByClassName('port').length; + document.getElementById('id_form-TOTAL_FORMS').value = + parseInt(document.getElementById('id_form-TOTAL_FORMS').value) + 1; + var new_port = document.createElement('div'); + new_port.className = 'port'; + new_port.innerHTML = template.replace(/__prefix__/g, new_index); + document.getElementById('formset').appendChild(new_port); + } + + document.addEventListener("DOMContentLoaded", function () { + document.getElementById("add_one").addEventListener("click", add_port, true); + }); + {% endblock %} - diff --git a/machines/templates/machines/index.html b/machines/templates/machines/index.html index 509334a0..ceef062c 100644 --- a/machines/templates/machines/index.html +++ b/machines/templates/machines/index.html @@ -29,10 +29,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "Machines" %}

- {% include "machines/aff_machines.html" with machines_list=machines_list %} -
-
-
+

{% trans "Machines" %}

+ {% include "machines/aff_machines.html" with machines_list=machines_list %} +
+
+
{% endblock %} - diff --git a/machines/templates/machines/index_alias.html b/machines/templates/machines/index_alias.html index 2d33177f..a2ffe66b 100644 --- a/machines/templates/machines/index_alias.html +++ b/machines/templates/machines/index_alias.html @@ -30,11 +30,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block content %}

{% trans "List of the aliases of the interface" %}

- {% trans " Add an alias" %} - {% trans " Delete one or several aliases" %} - {% include "machines/aff_alias.html" with alias_list=alias_list %} -
-
-
+ {% trans " Add an alias" %} + {% trans " Delete one or several aliases" %} + {% include "machines/aff_alias.html" with alias_list=alias_list %} +
+
+
{% endblock %} - diff --git a/machines/templates/machines/index_extension.html b/machines/templates/machines/index_extension.html index 6669d197..e689d479 100644 --- a/machines/templates/machines/index_extension.html +++ b/machines/templates/machines/index_extension.html @@ -24,67 +24,86 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} - {% load acl %} {% load i18n %} {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of extensions" %}

- {% can_create Extension %} - {% trans " Add an extension" %} - {% acl_end %} - {% trans " Delete one or several extensions" %} - {% include "machines/aff_extension.html" with extension_list=extension_list %} +

{% trans "List of extensions" %}

+ {% can_create Extension %} + + + {% trans " Add an extension" %} + {% acl_end %} + + {% trans " Delete one or several extensions" %} + + {% include "machines/aff_extension.html" with extension_list=extension_list %} -

{% trans "List of SOA records" %}

- {% can_create SOA %} - {% trans " Add an SOA record" %} - {% acl_end %} - {% trans " Delete one or several SOA records" %} - {% include "machines/aff_soa.html" with soa_list=soa_list %} +

{% trans "List of SOA records" %}

+ {% can_create SOA %} + + {% trans " Add an SOA record" %} + + {% acl_end %} + + {% trans " Delete one or several SOA records" %} + + {% include "machines/aff_soa.html" with soa_list=soa_list %} -

{% trans "List of MX records" %}

- {% can_create Mx %} - {% trans " Add an MX record" %} - {% acl_end %} - {% trans " Delete one or several MX records" %} - {% include "machines/aff_mx.html" with mx_list=mx_list %} +

{% trans "List of MX records" %}

+ {% can_create Mx %} + + {% trans " Add an MX record" %} + + {% acl_end %} + + {% trans " Delete one or several MX records" %} + + {% include "machines/aff_mx.html" with mx_list=mx_list %} -

{% trans "List of NS records" %}

- {% can_create Ns %} - {% trans " Add an NS record" %} - {% acl_end %} - {% trans " Delete one or several NS records" %} - {% include "machines/aff_ns.html" with ns_list=ns_list %} +

{% trans "List of NS records" %}

+ {% can_create Ns %} + + {% trans " Add an NS record" %} + + {% acl_end %} + + {% trans " Delete one or several NS records" %} + + {% include "machines/aff_ns.html" with ns_list=ns_list %} -

{% trans "List of TXT records" %}

- {% can_create Txt %} - {% trans " Add a TXT record" %} - {% acl_end %} - {% trans " Delete one or several TXT records" %} - {% include "machines/aff_txt.html" with txt_list=txt_list %} +

{% trans "List of TXT records" %}

+ {% can_create Txt %} + + {% trans " Add a TXT record" %} + + {% acl_end %} + + {% trans " Delete one or several TXT records" %} + + {% include "machines/aff_txt.html" with txt_list=txt_list %} -

{% trans "List of DNAME records" %}

- {% can_create DName %} - - {% trans " Add a DNAME record" %} - - {% acl_end %} - - {% trans " Delete one or several DNAME records" %} - - {% include "machines/aff_dname.html" with dname_list=dname_list %} - -

{% trans "List of SRV records" %}

- {% can_create Srv %} - {% trans " Add an SRV record" %} - {% acl_end %} - {% trans " Delete one or several SRV records" %} - {% include "machines/aff_srv.html" with srv_list=srv_list %} -
-
-
- {% endblock %} +

{% trans "List of DNAME records" %}

+ {% can_create DName %} + + {% trans " Add a DNAME record" %} + + {% acl_end %} + + {% trans " Delete one or several DNAME records" %} + + {% include "machines/aff_dname.html" with dname_list=dname_list %} +

{% trans "List of SRV records" %}

+ {% can_create Srv %} + + {% trans " Add an SRV record" %} + + {% acl_end %} + + {% trans " Delete one or several SRV records" %} + + {% include "machines/aff_srv.html" with srv_list=srv_list %} +{% endblock %} diff --git a/machines/templates/machines/index_iptype.html b/machines/templates/machines/index_iptype.html index 5be4561d..fea17993 100644 --- a/machines/templates/machines/index_iptype.html +++ b/machines/templates/machines/index_iptype.html @@ -24,21 +24,20 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} - {% load acl %} {% load i18n %} {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of IP types" %}

- {% can_create IpType %} - {% trans " Add an IP type" %} - {% acl_end %} - {% trans " Delete one or several IP types" %} - {% include "machines/aff_iptype.html" with iptype_list=iptype_list %} -
-
-
+

{% trans "List of IP types" %}

+ {% can_create IpType %} + + {% trans " Add an IP type" %} + + {% acl_end %} + + {% trans " Delete one or several IP types" %} + + {% include "machines/aff_iptype.html" with iptype_list=iptype_list %} {% endblock %} - diff --git a/machines/templates/machines/index_ipv6.html b/machines/templates/machines/index_ipv6.html index 06e287e2..2ab2231e 100644 --- a/machines/templates/machines/index_ipv6.html +++ b/machines/templates/machines/index_ipv6.html @@ -30,13 +30,14 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of the IPv6 addresses of the interface" %}

- {% can_create Ipv6List interface_id %} - {% trans " Add an IPv6 address" %} - {% acl_end %} - {% include "machines/aff_ipv6.html" with ipv6_list=ipv6_list %} -
-
-
+

{% trans "List of the IPv6 addresses of the interface" %}

+ {% can_create Ipv6List interface_id %} + + {% trans " Add an IPv6 address" %} + + {% acl_end %} + {% include "machines/aff_ipv6.html" with ipv6_list=ipv6_list %} +
+
+
{% endblock %} - diff --git a/machines/templates/machines/index_machinetype.html b/machines/templates/machines/index_machinetype.html index de1e2f58..5d184e29 100644 --- a/machines/templates/machines/index_machinetype.html +++ b/machines/templates/machines/index_machinetype.html @@ -31,14 +31,17 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of machine types" %}

- {% can_create MachineType %} - {% trans " Add a machine type" %} - {% acl_end %} - {% trans " Delete one or several machine types" %} - {% include "machines/aff_machinetype.html" with machinetype_list=machinetype_list %} -
-
-
+

{% trans "List of machine types" %}

+ {% can_create MachineType %} + + {% trans " Add a machine type" %} + + {% acl_end %} + + {% trans " Delete one or several machine types" %} + + {% include "machines/aff_machinetype.html" with machinetype_list=machinetype_list %} +
+
+
{% endblock %} - diff --git a/machines/templates/machines/index_nas.html b/machines/templates/machines/index_nas.html index 88f68213..c4da9779 100644 --- a/machines/templates/machines/index_nas.html +++ b/machines/templates/machines/index_nas.html @@ -31,15 +31,18 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of NAS devices" %}

-
{% trans "The NAS device type and machine type are linked. It is useful for MAC address auto capture by RADIUS, and allows to choose the machine type to assign to the machines according to the NAS device type." %}
- {% can_create Nas %} - {% trans " Add a NAS device type" %} - {% acl_end %} - {% trans " Delete one or several NAS device types" %} - {% include "machines/aff_nas.html" with nas_list=nas_list %} -
-
-
+

{% trans "List of NAS devices" %}

+
{% trans "The NAS device type and machine type are linked. It is useful for MAC address auto capture by RADIUS, and allows to choose the machine type to assign to the machines according to the NAS device type." %}
+ {% can_create Nas %} + + {% trans " Add a NAS device type" %} + + {% acl_end %} + + {% trans " Delete one or several NAS device types" %} + + {% include "machines/aff_nas.html" with nas_list=nas_list %} +
+
+
{% endblock %} - diff --git a/machines/templates/machines/index_portlist.html b/machines/templates/machines/index_portlist.html index 0d3d0741..c6659b65 100644 --- a/machines/templates/machines/index_portlist.html +++ b/machines/templates/machines/index_portlist.html @@ -8,60 +8,58 @@ {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of ports configurations" %}

- {% can_create OuverturePortList %} - {% trans " Add a configuration" %} - {% acl_end %} - - - - - - - - - - - - - {% for pl in port_list %} - - - - - - - - - {%endfor%} -
{% trans "Name" %}{% trans "TCP (input)" %}{% trans "TCP (output)" %}{% trans "UDP (input)" %}{% trans "UDP (output)" %}{% trans "Machines" %}
{{pl.name}}{% for p in pl.tcp_ports_in %}{{p.show_port}}, {%endfor%}{% for p in pl.tcp_ports_out %}{{p.show_port}}, {%endfor%}{% for p in pl.udp_ports_in %}{{p.show_port}}, {%endfor%}{% for p in pl.udp_ports_out %}{{p.show_port}}, {%endfor%} - {% if pl.interface_set.all %} - - {% endif %} - - {% can_edit pl %} - {% include 'buttons/edit.html' with href='machines:edit-portlist' id=pl.id %} - {% acl_end %} - {% can_delete pl %} - {% include 'buttons/suppr.html' with href='machines:del-portlist' id=pl.id %} - {% acl_end %} -
-
-
-
- +

{% trans "List of ports configurations" %}

+ {% can_create OuverturePortList %} + + {% trans " Add a configuration" %} + + {% acl_end %} + + + + + + + + + + + + + {% for pl in port_list %} + + + + + + + + + {% endfor %} +
{% trans "Name" %}{% trans "TCP (input)" %}{% trans "TCP (output)" %}{% trans "UDP (input)" %}{% trans "UDP (output)" %}{% trans "Machines" %}
{{ pl.name }}{% for p in pl.tcp_ports_in %}{{ p.show_port }}, {% endfor %}{% for p in pl.tcp_ports_out %}{{ p.show_port }}, {% endfor %}{% for p in pl.udp_ports_in %}{{ p.show_port }}, {% endfor %}{% for p in pl.udp_ports_out %}{{ p.show_port }}, {% endfor %} + {% if pl.interface_set.all %} + + {% endif %} + + {% can_edit pl %} + {% include 'buttons/edit.html' with href='machines:edit-portlist' id=pl.id %} + {% acl_end %} + {% can_delete pl %} + {% include 'buttons/suppr.html' with href='machines:del-portlist' id=pl.id %} + {% acl_end %} +
{% endblock %} - diff --git a/machines/templates/machines/index_role.html b/machines/templates/machines/index_role.html index ddc2ea8b..3271bc43 100644 --- a/machines/templates/machines/index_role.html +++ b/machines/templates/machines/index_role.html @@ -30,13 +30,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of roles" %}

- {% can_create Role %} - {% trans " Add a role"%} - {% acl_end %} - {% trans " Delete one or several roles" %} - {% include "machines/aff_role.html" with role_list=role_list %} -
-
+

{% trans "List of roles" %}

+ {% can_create Role %} + {% trans " Add a role" %} + {% acl_end %} + {% trans " Delete one or several roles" %} + {% include "machines/aff_role.html" with role_list=role_list %} {% endblock %} - diff --git a/machines/templates/machines/index_service.html b/machines/templates/machines/index_service.html index 9dec7032..a41c79c6 100644 --- a/machines/templates/machines/index_service.html +++ b/machines/templates/machines/index_service.html @@ -30,16 +30,15 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of services" %}

- {% can_create machines.Service %} - {% trans " Add a service" %} - {% acl_end %} - {% trans " Delete one or several services" %} - {% include "machines/aff_service.html" with service_list=service_list %} -

{% trans "States of servers" %}

- {% include "machines/aff_servers.html" with servers_list=servers_list %} -
-
-
-{% endblock %} +

{% trans "List of services" %}

+ {% can_create machines.Service %} + {% trans " Add a service" %} + {% acl_end %} + {% trans " Delete one or several services" %} + {% include "machines/aff_service.html" with service_list=service_list %} +

{% trans "States of servers" %}

+ {% include "machines/aff_servers.html" with servers_list=servers_list %} +{% endblock %} diff --git a/machines/templates/machines/index_sshfp.html b/machines/templates/machines/index_sshfp.html index ce16d621..0233bac4 100644 --- a/machines/templates/machines/index_sshfp.html +++ b/machines/templates/machines/index_sshfp.html @@ -34,6 +34,5 @@ with this program; if not, write to the Free Software Foundation, Inc., {% trans " Add an SSH fingerprint" %} {% acl_end %} - {% include "machines/aff_sshfp.html" with sshfp_list=sshfp_list %} + {% include "machines/aff_sshfp.html" with sshfp_list=sshfp_list %} {% endblock %} - diff --git a/machines/templates/machines/index_vlan.html b/machines/templates/machines/index_vlan.html index 7af31fd5..f34f3ebb 100644 --- a/machines/templates/machines/index_vlan.html +++ b/machines/templates/machines/index_vlan.html @@ -24,21 +24,18 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} - {% load acl %} {% load i18n %} {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -

{% trans "List of VLANs" %}

- {% can_create Vlan %} - {% trans " Add a VLAN" %} - {% acl_end %} - {% trans " Delete one or several VLANs" %} - {% include "machines/aff_vlan.html" with vlan_list=vlan_list %} -
-
-
+

{% trans "List of VLANs" %}

+ {% can_create Vlan %} + {% trans " Add a VLAN" %} + {% acl_end %} + {% trans " Delete one or several VLANs" %} + {% include "machines/aff_vlan.html" with vlan_list=vlan_list %} {% endblock %} - diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html index ed6529d0..1a8ce8b1 100644 --- a/machines/templates/machines/machine.html +++ b/machines/templates/machines/machine.html @@ -31,147 +31,143 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Machines" %}{% endblock %} {% block content %} -{% if machineform %} - {% bootstrap_form_errors machineform %} -{% endif %} -{% if interfaceform %} - {% bootstrap_form_errors interfaceform %} -{% endif %} -{% if domainform %} - {% bootstrap_form_errors domainform %} -{% endif %} -{% if iptypeform %} - {% bootstrap_form_errors iptypeform %} -{% endif %} -{% if machinetypeform %} - {% bootstrap_form_errors machinetypeform %} -{% endif %} -{% if extensionform %} - {% bootstrap_form_errors extensionform %} -{% endif %} -{% if mxform %} - {% bootstrap_form_errors mxform %} -{% endif %} -{% if nsform %} - {% bootstrap_form_errors nsform %} -{% endif %} -{% if txtform %} - {% bootstrap_form_errors txtform %} -{% endif %} -{% if dnameform %} - {% bootstrap_form_errors dnameform %} -{% endif %} -{% if srvform %} - {% bootstrap_form_errors srvform %} -{% endif %} -{% if aliasform %} - {% bootstrap_form_errors aliasform %} -{% endif %} -{% if serviceform %} - {% bootstrap_form_errors serviceform %} -{% endif %} -{% if sshfpform %} - {% bootstrap_form_errors sshfpform %} -{% endif %} -{% if roleform %} - {% bootstrap_form_errors roleform %} -{% endif %} -{% if vlanform %} - {% bootstrap_form_errors vlanform %} -{% endif %} -{% if nasform %} - {% bootstrap_form_errors nasform %} -{% endif %} -{% if ipv6form %} - {% bootstrap_form_errors ipv6form %} -{% endif %} - -
- {% csrf_token %} {% if machineform %} -

{% trans "Machine" %}

- {% massive_bootstrap_form machineform 'user' %} + {% bootstrap_form_errors machineform %} {% endif %} {% if interfaceform %} -

{% trans "Interface" %}

- {% if i_mbf_param %} - {% massive_bootstrap_form interfaceform 'ipv4,machine' mbf_param=i_mbf_param %} - {% else %} - {% massive_bootstrap_form interfaceform 'ipv4,machine' %} - {% endif %} + {% bootstrap_form_errors interfaceform %} {% endif %} {% if domainform %} -

{% trans "Domain" %}

- {% bootstrap_form domainform %} + {% bootstrap_form_errors domainform %} {% endif %} {% if iptypeform %} -

{% trans "IP type" %}

- {% bootstrap_form iptypeform %} + {% bootstrap_form_errors iptypeform %} {% endif %} {% if machinetypeform %} -

{% trans "Machine type" %}

- {% bootstrap_form machinetypeform %} + {% bootstrap_form_errors machinetypeform %} {% endif %} {% if extensionform %} -

{% trans "Extension" %}

- {% massive_bootstrap_form extensionform 'origin' %} - {% endif %} - {% if soaform %} -

{% trans "SOA record" %}

- {% bootstrap_form soaform %} + {% bootstrap_form_errors extensionform %} {% endif %} {% if mxform %} -

{% trans "MX record" %}

- {% massive_bootstrap_form mxform 'name' %} + {% bootstrap_form_errors mxform %} {% endif %} {% if nsform %} -

{% trans "NS record" %}

- {% massive_bootstrap_form nsform 'ns' %} + {% bootstrap_form_errors nsform %} {% endif %} {% if txtform %} -

{% trans "TXT record" %}

- {% bootstrap_form txtform %} + {% bootstrap_form_errors txtform %} {% endif %} {% if dnameform %} -

{% trans "DNAME record" %}

- {% bootstrap_form dnameform %} + {% bootstrap_form_errors dnameform %} {% endif %} {% if srvform %} -

{% trans "SRV record" %}

- {% massive_bootstrap_form srvform 'target' %} - {% endif %} - {% if sshfpform %} -

{% trans "SSHFP record" %}

- {% bootstrap_form sshfpform %} + {% bootstrap_form_errors srvform %} {% endif %} {% if aliasform %} -

{% trans "Alias" %}

- {% bootstrap_form aliasform %} + {% bootstrap_form_errors aliasform %} {% endif %} {% if serviceform %} -

{% trans "Service" %}

- {% massive_bootstrap_form serviceform 'servers' %} + {% bootstrap_form_errors serviceform %} + {% endif %} + {% if sshfpform %} + {% bootstrap_form_errors sshfpform %} {% endif %} {% if roleform %} -

Role

- {% massive_bootstrap_form roleform 'servers' %} + {% bootstrap_form_errors roleform %} {% endif %} {% if vlanform %} -

{% trans "VLAN" %}

- {% bootstrap_form vlanform %} + {% bootstrap_form_errors vlanform %} {% endif %} {% if nasform %} -

{% trans "NAS device" %}

- {% bootstrap_form nasform %} + {% bootstrap_form_errors nasform %} {% endif %} {% if ipv6form %} -

{% trans "IPv6 address" %}

- {% bootstrap_form ipv6form %} + {% bootstrap_form_errors ipv6form %} {% endif %} - {% bootstrap_button action_name button_type="submit" icon='ok' button_class='btn-success' %} -
-
-
-
-{% endblock %} +
+ {% csrf_token %} + {% if machineform %} +

{% trans "Machine" %}

+ {% massive_bootstrap_form machineform 'user' %} + {% endif %} + {% if interfaceform %} +

{% trans "Interface" %}

+ {% if i_mbf_param %} + {% massive_bootstrap_form interfaceform 'ipv4,machine' mbf_param=i_mbf_param %} + {% else %} + {% massive_bootstrap_form interfaceform 'ipv4,machine' %} + {% endif %} + {% endif %} + {% if domainform %} +

{% trans "Domain" %}

+ {% bootstrap_form domainform %} + {% endif %} + {% if iptypeform %} +

{% trans "IP type" %}

+ {% bootstrap_form iptypeform %} + {% endif %} + {% if machinetypeform %} +

{% trans "Machine type" %}

+ {% bootstrap_form machinetypeform %} + {% endif %} + {% if extensionform %} +

{% trans "Extension" %}

+ {% massive_bootstrap_form extensionform 'origin' %} + {% endif %} + {% if soaform %} +

{% trans "SOA record" %}

+ {% bootstrap_form soaform %} + {% endif %} + {% if mxform %} +

{% trans "MX record" %}

+ {% massive_bootstrap_form mxform 'name' %} + {% endif %} + {% if nsform %} +

{% trans "NS record" %}

+ {% massive_bootstrap_form nsform 'ns' %} + {% endif %} + {% if txtform %} +

{% trans "TXT record" %}

+ {% bootstrap_form txtform %} + {% endif %} + {% if dnameform %} +

{% trans "DNAME record" %}

+ {% bootstrap_form dnameform %} + {% endif %} + {% if srvform %} +

{% trans "SRV record" %}

+ {% massive_bootstrap_form srvform 'target' %} + {% endif %} + {% if sshfpform %} +

{% trans "SSHFP record" %}

+ {% bootstrap_form sshfpform %} + {% endif %} + {% if aliasform %} +

{% trans "Alias" %}

+ {% bootstrap_form aliasform %} + {% endif %} + {% if serviceform %} +

{% trans "Service" %}

+ {% massive_bootstrap_form serviceform 'servers' %} + {% endif %} + {% if roleform %} +

Role

+ {% massive_bootstrap_form roleform 'servers' %} + {% endif %} + {% if vlanform %} +

{% trans "VLAN" %}

+ {% bootstrap_form vlanform %} + {% endif %} + {% if nasform %} +

{% trans "NAS device" %}

+ {% bootstrap_form nasform %} + {% endif %} + {% if ipv6form %} +

{% trans "IPv6 address" %}

+ {% bootstrap_form ipv6form %} + {% endif %} + {% bootstrap_button action_name button_type="submit" icon='ok' button_class='btn-success' %} +
+{% endblock %} diff --git a/machines/templates/machines/sidebar.html b/machines/templates/machines/sidebar.html index 68e14ae0..81c83ab9 100644 --- a/machines/templates/machines/sidebar.html +++ b/machines/templates/machines/sidebar.html @@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_view_all Machine %} - {% trans "Machines" %} + {% trans "Machines" %} {% acl_end %} {% can_view_all MachineType %} @@ -42,31 +42,31 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_view_all Extension %} - {% trans "Extensions and zones" %} + {% trans "Extensions and zones" %} {% acl_end %} {% can_view_all IpType %} - {% trans "IP ranges" %} + {% trans "IP ranges" %} {% acl_end %} {% can_view_all Vlan %} - {% trans "VLANs" %} + {% trans "VLANs" %} {% acl_end %} {% can_view_all Nas %} - {% trans "NAS devices" %} + {% trans "NAS devices" %} {% acl_end %} {% can_view_all machines.Service %} - {% trans "Services (DHCP, DNS, ...)" %} + {% trans "Services (DHCP, DNS, ...)" %} {% acl_end %} {% can_view_all Role %} @@ -78,8 +78,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_view_all OuverturePortList %} - {% trans "Ports openings" %} + {% trans "Ports openings" %} {% acl_end %} {% endblock %} - From 48d5ab108c306f4ab9bd3f4e069e55519d36f949 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 24 Sep 2018 19:31:23 +0200 Subject: [PATCH 2/2] Autoformat code --- machines/acl.py | 1 - machines/admin.py | 5 +- machines/forms.py | 44 ++++++++++---- machines/models.py | 131 +++++++++++++++++++--------------------- machines/serializers.py | 14 ++--- machines/urls.py | 1 + machines/views.py | 127 +++++++++++++++++++------------------- 7 files changed, 169 insertions(+), 154 deletions(-) diff --git a/machines/acl.py b/machines/acl.py index 45cb6ec2..53f70c27 100644 --- a/machines/acl.py +++ b/machines/acl.py @@ -41,4 +41,3 @@ def can_view(user): can = user.has_module_perms('machines') return can, None if can else _("You don't have the right to view this" " application.") - diff --git a/machines/admin.py b/machines/admin.py index af721ff9..bafebb80 100644 --- a/machines/admin.py +++ b/machines/admin.py @@ -29,7 +29,6 @@ from __future__ import unicode_literals from django.contrib import admin from reversion.admin import VersionAdmin -from .models import IpType, Machine, MachineType, Domain, IpList, Interface from .models import ( Extension, SOA, @@ -47,6 +46,7 @@ from .models import ( Ipv6List, OuverturePortList, ) +from .models import IpType, Machine, MachineType, Domain, IpList, Interface class MachineAdmin(VersionAdmin): @@ -98,6 +98,7 @@ class TxtAdmin(VersionAdmin): """ Admin view of a TXT object """ pass + class DNameAdmin(VersionAdmin): """ Admin view of a DName object """ pass @@ -147,12 +148,12 @@ class ServiceAdmin(VersionAdmin): """ Admin view of a ServiceAdmin object """ list_display = ('service_type', 'min_time_regen', 'regular_time_regen') + class RoleAdmin(VersionAdmin): """ Admin view of a RoleAdmin object """ pass - admin.site.register(Machine, MachineAdmin) admin.site.register(MachineType, MachineTypeAdmin) admin.site.register(IpType, IpTypeAdmin) diff --git a/machines/forms.py b/machines/forms.py index e9c75d59..abc96811 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -35,13 +35,12 @@ Formulaires d'ajout, edition et suppressions de : from __future__ import unicode_literals -from django.forms import ModelForm, Form from django import forms +from django.forms import ModelForm, Form from django.utils.translation import ugettext_lazy as _ from re2o.field_permissions import FieldPermissionFormMixin from re2o.mixins import FormRevMixin - from .models import ( Domain, Machine, @@ -68,6 +67,7 @@ from .models import ( class EditMachineForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): """Formulaire d'édition d'une machine""" + class Meta: model = Machine fields = '__all__' @@ -80,12 +80,14 @@ class EditMachineForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): class NewMachineForm(EditMachineForm): """Creation d'une machine, ne renseigne que le nom""" + class Meta(EditMachineForm.Meta): fields = ['name'] class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): """Edition d'une interface. Edition complète""" + class Meta: model = Interface fields = ['machine', 'type', 'ipv4', 'mac_address', 'details'] @@ -116,7 +118,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): interface=self.instance ) if "machine" in self.fields: - self.fields['machine'].queryset = Machine.objects.all()\ + self.fields['machine'].queryset = Machine.objects.all() \ .select_related('user') can_use_all_machinetype, _reason = MachineType.can_use_all(user) if not can_use_all_machinetype: @@ -128,12 +130,14 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): class AddInterfaceForm(EditInterfaceForm): """Ajout d'une interface à une machine. En fonction des droits, affiche ou non l'ensemble des ip disponibles""" + class Meta(EditInterfaceForm.Meta): fields = ['type', 'ipv4', 'mac_address', 'details'] class AliasForm(FormRevMixin, ModelForm): """Ajout d'un alias (et edition), CNAME, contenant nom et extension""" + class Meta: model = Domain fields = ['name', 'extension'] @@ -151,6 +155,7 @@ class AliasForm(FormRevMixin, ModelForm): class DomainForm(FormRevMixin, ModelForm): """Ajout et edition d'un enregistrement de nom, relié à interface""" + class Meta: model = Domain fields = ['name'] @@ -183,6 +188,7 @@ class DelAliasForm(FormRevMixin, Form): class MachineTypeForm(FormRevMixin, ModelForm): """Ajout et edition d'un machinetype, relié à un iptype""" + class Meta: model = MachineType fields = ['type', 'ip_type'] @@ -214,6 +220,7 @@ class DelMachineTypeForm(FormRevMixin, Form): class IpTypeForm(FormRevMixin, ModelForm): """Formulaire d'ajout d'un iptype. Pas d'edition de l'ip de start et de stop après creation""" + class Meta: model = IpType fields = '__all__' @@ -227,6 +234,7 @@ class IpTypeForm(FormRevMixin, ModelForm): class EditIpTypeForm(IpTypeForm): """Edition d'un iptype. Pas d'edition du rangev4 possible, car il faudrait synchroniser les objets iplist""" + class Meta(IpTypeForm.Meta): fields = ['extension', 'type', 'need_infra', 'domaine_ip_network', 'domaine_ip_netmask', 'prefix_v6', 'prefix_v6_length', @@ -253,6 +261,7 @@ class DelIpTypeForm(FormRevMixin, Form): class ExtensionForm(FormRevMixin, ModelForm): """Formulaire d'ajout et edition d'une extension""" + class Meta: model = Extension fields = '__all__' @@ -285,6 +294,7 @@ class DelExtensionForm(FormRevMixin, Form): class Ipv6ListForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): """Gestion des ipv6 d'une machine""" + class Meta: model = Ipv6List fields = ['ipv6', 'slaac_ip'] @@ -296,6 +306,7 @@ class Ipv6ListForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): class SOAForm(FormRevMixin, ModelForm): """Ajout et edition d'un SOA""" + class Meta: model = SOA fields = '__all__' @@ -324,6 +335,7 @@ class DelSOAForm(FormRevMixin, Form): class MxForm(FormRevMixin, ModelForm): """Ajout et edition d'un MX""" + class Meta: model = Mx fields = ['zone', 'priority', 'name'] @@ -357,6 +369,7 @@ class NsForm(FormRevMixin, ModelForm): """Ajout d'un NS pour une zone On exclue les CNAME dans les objets domain (interdit par la rfc) donc on prend uniquemet """ + class Meta: model = Ns fields = ['zone', 'ns'] @@ -388,6 +401,7 @@ class DelNsForm(FormRevMixin, Form): class TxtForm(FormRevMixin, ModelForm): """Ajout d'un txt pour une zone""" + class Meta: model = Txt fields = '__all__' @@ -416,6 +430,7 @@ class DelTxtForm(FormRevMixin, Form): class DNameForm(FormRevMixin, ModelForm): """Add a DNAME entry for a zone""" + class Meta: model = DName fields = '__all__' @@ -444,6 +459,7 @@ class DelDNameForm(FormRevMixin, Form): class SrvForm(FormRevMixin, ModelForm): """Ajout d'un srv pour une zone""" + class Meta: model = Srv fields = '__all__' @@ -473,6 +489,7 @@ class DelSrvForm(FormRevMixin, Form): class NasForm(FormRevMixin, ModelForm): """Ajout d'un type de nas (machine d'authentification, swicths, bornes...)""" + class Meta: model = Nas fields = '__all__' @@ -501,6 +518,7 @@ class DelNasForm(FormRevMixin, Form): class RoleForm(FormRevMixin, ModelForm): """Add and edit role.""" + class Meta: model = Role fields = '__all__' @@ -509,9 +527,9 @@ class RoleForm(FormRevMixin, ModelForm): prefix = kwargs.pop('prefix', self.Meta.model.__name__) super(RoleForm, self).__init__(*args, prefix=prefix, **kwargs) self.fields['servers'].queryset = (Interface.objects.all() - .select_related( - 'domain__extension' - )) + .select_related( + 'domain__extension' + )) class DelRoleForm(FormRevMixin, Form): @@ -533,6 +551,7 @@ class DelRoleForm(FormRevMixin, Form): class ServiceForm(FormRevMixin, ModelForm): """Ajout et edition d'une classe de service : dns, dhcp, etc""" + class Meta: model = Service fields = '__all__' @@ -541,9 +560,9 @@ class ServiceForm(FormRevMixin, ModelForm): prefix = kwargs.pop('prefix', self.Meta.model.__name__) super(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs) self.fields['servers'].queryset = (Interface.objects.all() - .select_related( - 'domain__extension' - )) + .select_related( + 'domain__extension' + )) def save(self, commit=True): # TODO : None of the parents of ServiceForm use the commit @@ -574,6 +593,7 @@ class DelServiceForm(FormRevMixin, Form): class VlanForm(FormRevMixin, ModelForm): """Ajout d'un vlan : id, nom""" + class Meta: model = Vlan fields = ['vlan_id', 'name', 'comment'] @@ -614,6 +634,7 @@ class DelVlanForm(FormRevMixin, Form): class EditOuverturePortConfigForm(FormRevMixin, ModelForm): """Edition de la liste des profils d'ouverture de ports pour l'interface""" + class Meta: model = Interface fields = ['port_lists'] @@ -630,6 +651,7 @@ class EditOuverturePortConfigForm(FormRevMixin, ModelForm): class EditOuverturePortListForm(FormRevMixin, ModelForm): """Edition de la liste des ports et profils d'ouverture des ports""" + class Meta: model = OuverturePortList fields = '__all__' @@ -642,9 +664,10 @@ class EditOuverturePortListForm(FormRevMixin, ModelForm): **kwargs ) - + class SshFpForm(FormRevMixin, ModelForm): """Edits a SSHFP record.""" + class Meta: model = SshFp exclude = ('machine',) @@ -656,4 +679,3 @@ class SshFpForm(FormRevMixin, ModelForm): prefix=prefix, **kwargs ) - diff --git a/machines/models.py b/machines/models.py index 74fc01a1..282fc1ab 100644 --- a/machines/models.py +++ b/machines/models.py @@ -27,32 +27,30 @@ The models definitions for the Machines app from __future__ import unicode_literals -from datetime import timedelta +import base64 +import hashlib import re +from datetime import timedelta from ipaddress import IPv6Address from itertools import chain -from netaddr import mac_bare, EUI, IPSet, IPRange, IPNetwork, IPAddress -import hashlib -import base64 +from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from django.db.models import Q from django.db.models.signals import post_save, post_delete from django.dispatch import receiver from django.forms import ValidationError -from django.utils.functional import cached_property from django.utils import timezone -from django.core.validators import MaxValueValidator, MinValueValidator +from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ - from macaddress.fields import MACAddressField +from netaddr import mac_bare, EUI, IPSet, IPRange, IPNetwork, IPAddress +import preferences.models +import users.models from re2o.field_permissions import FieldPermissionModelMixin from re2o.mixins import AclMixin, RevMixin -import users.models -import preferences.models - class Machine(RevMixin, FieldPermissionModelMixin, models.Model): """ Class définissant une machine, object parent user, objets fils @@ -116,7 +114,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): :return: True ou False avec la raison de l'échec le cas échéant""" if not user_request.has_perm('machines.view_machine'): return False, _("You don't have the right to view all the" - " machines.") + " machines.") return True, None @staticmethod @@ -131,9 +129,9 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): except users.models.User.DoesNotExist: return False, _("Nonexistent user.") max_lambdauser_interfaces = (preferences.models.OptionalMachine - .get_cached_value( - 'max_lambdauser_interfaces' - )) + .get_cached_value( + 'max_lambdauser_interfaces' + )) if not user_request.has_perm('machines.add_machine'): if not (preferences.models.OptionalMachine .get_cached_value('create_machine')): @@ -180,7 +178,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): **kwargs )[0]): return False, _("You don't have the right to delete a machine" - " of another user.") + " of another user.") return True, None def can_view(self, user_request, *_args, **_kwargs): @@ -192,7 +190,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): if (not user_request.has_perm('machines.view_machine') and self.user != user_request): return False, _("You don't have the right to view other machines" - " than yours.") + " than yours.") return True, None @cached_property @@ -213,14 +211,14 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): machine""" return Domain.objects.filter( interface_parent__machine=self - ).values_list('name', flat=True).distinct() + ).values_list('name', flat=True).distinct() @cached_property def all_complete_names(self): """Renvoie tous les tls complets de la machine""" return [str(domain) for domain in Domain.objects.filter( Q(cname__interface_parent__machine=self) | Q(interface_parent__machine=self) - )] + )] def __init__(self, *args, **kwargs): super(Machine, self).__init__(*args, **kwargs) @@ -296,8 +294,8 @@ class IpType(RevMixin, AclMixin, models.Model): help_text=_("Netmask for the domain's IPv4 range") ) reverse_v4 = models.BooleanField( - default=False, - help_text=_("Enable reverse DNS for IPv4"), + default=False, + help_text=_("Enable reverse DNS for IPv4"), ) prefix_v6 = models.GenericIPAddressField( protocol='IPv6', @@ -310,10 +308,10 @@ class IpType(RevMixin, AclMixin, models.Model): MaxValueValidator(128), MinValueValidator(0) ] - ) + ) reverse_v6 = models.BooleanField( - default=False, - help_text=_("Enable reverse DNS for IPv6"), + default=False, + help_text=_("Enable reverse DNS for IPv6"), ) vlan = models.ForeignKey( 'Vlan', @@ -333,7 +331,7 @@ class IpType(RevMixin, AclMixin, models.Model): ("use_all_iptype", _("Can use all IP types")), ) verbose_name = _("IP type") - verbose_name_plural = ("IP types") + verbose_name_plural = "IP types" @cached_property def ip_range(self): @@ -373,9 +371,9 @@ class IpType(RevMixin, AclMixin, models.Model): def ip6_set_full_info(self): if self.prefix_v6: return { - 'network' : str(self.prefix_v6), - 'netmask' : 'ffff:ffff:ffff:ffff::', - 'netmask_cidr' : str(self.prefix_v6_length), + 'network': str(self.prefix_v6), + 'netmask': 'ffff:ffff:ffff:ffff::', + 'netmask_cidr': str(self.prefix_v6_length), 'vlan': str(self.vlan), 'vlan_id': self.vlan.vlan_id } @@ -394,10 +392,10 @@ class IpType(RevMixin, AclMixin, models.Model): def ip_net_full_info(self): """Renvoie les infos du network contenant du range""" return { - 'network' : str(self.ip_network.network), - 'netmask' : str(self.ip_network.netmask), - 'broadcast' : str(self.ip_network.broadcast), - 'netmask_cidr' : str(self.ip_network.prefixlen), + 'network': str(self.ip_network.network), + 'netmask': str(self.ip_network.netmask), + 'broadcast': str(self.ip_network.broadcast), + 'netmask_cidr': str(self.ip_network.prefixlen), } @cached_property @@ -448,9 +446,9 @@ class IpType(RevMixin, AclMixin, models.Model): return else: for ipv6 in Ipv6List.objects.filter( - interface__in=Interface.objects.filter( - type__in=MachineType.objects.filter(ip_type=self) - ) + interface__in=Interface.objects.filter( + type__in=MachineType.objects.filter(ip_type=self) + ) ): ipv6.check_and_replace_prefix(prefix=self.prefix_v6) @@ -814,8 +812,8 @@ class Txt(RevMixin, AclMixin, models.Model): verbose_name_plural = _("TXT records") def __str__(self): - return str(self.zone) + " : " + str(self.field1) + " " +\ - str(self.field2) + return str(self.zone) + " : " + str(self.field1) + " " + \ + str(self.field2) @cached_property def dns_entry(self): @@ -874,7 +872,7 @@ class Srv(RevMixin, AclMixin, models.Model): default=0, validators=[MaxValueValidator(65535)], help_text=_("Relative weight for records with the same priority" - " (integer value between 0 and 65535)") + " (integer value between 0 and 65535)") ) port = models.PositiveIntegerField( validators=[MaxValueValidator(65535)], @@ -894,17 +892,17 @@ class Srv(RevMixin, AclMixin, models.Model): verbose_name_plural = _("SRV records") def __str__(self): - return str(self.service) + ' ' + str(self.protocole) + ' ' +\ - str(self.extension) + ' ' + str(self.priority) +\ - ' ' + str(self.weight) + str(self.port) + str(self.target) + return str(self.service) + ' ' + str(self.protocole) + ' ' + \ + str(self.extension) + ' ' + str(self.priority) + \ + ' ' + str(self.weight) + str(self.port) + str(self.target) @cached_property def dns_entry(self): """Renvoie l'enregistrement SRV complet pour le fichier de zone""" - return str(self.service) + '._' + str(self.protocole).lower() +\ - str(self.extension) + '. ' + str(self.ttl) + ' IN SRV ' +\ - str(self.priority) + ' ' + str(self.weight) + ' ' +\ - str(self.port) + ' ' + str(self.target) + '.' + return str(self.service) + '._' + str(self.protocole).lower() + \ + str(self.extension) + '. ' + str(self.ttl) + ' IN SRV ' + \ + str(self.priority) + ' ' + str(self.weight) + ' ' + \ + str(self.port) + ' ' + str(self.target) + '.' class SshFp(RevMixin, AclMixin, models.Model): @@ -949,8 +947,8 @@ class SshFp(RevMixin, AclMixin, models.Model): """Return the hashess for the pub key with correct id cf RFC, 1 is sha1 , 2 sha256""" return { - "1" : hashlib.sha1(base64.b64decode(self.pub_key_entry)).hexdigest(), - "2" : hashlib.sha256(base64.b64decode(self.pub_key_entry)).hexdigest(), + "1": hashlib.sha1(base64.b64decode(self.pub_key_entry)).hexdigest(), + "2": hashlib.sha256(base64.b64decode(self.pub_key_entry)).hexdigest(), } class Meta: @@ -973,7 +971,6 @@ class SshFp(RevMixin, AclMixin, models.Model): return str(self.algo) + ' ' + str(self.comment) - class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): """ Une interface. Objet clef de l'application machine : - une address mac unique. Possibilité de la rendre unique avec le @@ -1067,7 +1064,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): .get_cached_value('ipv6_mode') == 'SLAAC'): self.sync_ipv6_slaac() elif (preferences.models.OptionalMachine - .get_cached_value('ipv6_mode') == 'DHCPV6'): + .get_cached_value('ipv6_mode') == 'DHCPV6'): self.sync_ipv6_dhcpv6() else: return @@ -1080,7 +1077,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): .get_cached_value('ipv6_mode') == 'SLAAC'): return self.ipv6list.all() elif (preferences.models.OptionalMachine - .get_cached_value('ipv6_mode') == 'DHCPV6'): + .get_cached_value('ipv6_mode') == 'DHCPV6'): return self.ipv6list.filter(slaac_ip=False) else: return None @@ -1159,9 +1156,9 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): .get_cached_value('create_machine')): return False, _("You can't add a machine.") max_lambdauser_interfaces = (preferences.models.OptionalMachine - .get_cached_value( - 'max_lambdauser_interfaces' - )) + .get_cached_value( + 'max_lambdauser_interfaces' + )) if machine.user != user_request: return False, _("You don't have the right to add an interface" " to a machine of another user.") @@ -1365,8 +1362,8 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): def clean(self, *args, **kwargs): if self.slaac_ip and (Ipv6List.objects - .filter(interface=self.interface, slaac_ip=True) - .exclude(id=self.id)): + .filter(interface=self.interface, slaac_ip=True) + .exclude(id=self.id)): raise ValidationError(_("A SLAAC IP address is already registered.")) prefix_v6 = self.interface.type.ip_type.prefix_v6.encode().decode('utf-8') if prefix_v6: @@ -1498,18 +1495,18 @@ class Domain(RevMixin, AclMixin, models.Model): return False, _("Nonexistent interface.") if not user_request.has_perm('machines.add_domain'): max_lambdauser_aliases = (preferences.models.OptionalMachine - .get_cached_value( - 'max_lambdauser_aliases' - )) + .get_cached_value( + 'max_lambdauser_aliases' + )) if interface.machine.user != user_request: return False, _("You don't have the right to add an alias to a" " machine of another user.") if Domain.objects.filter( cname__in=Domain.objects.filter( interface_parent__in=(interface.machine.user - .user_interfaces()) + .user_interfaces()) ) - ).count() >= max_lambdauser_aliases: + ).count() >= max_lambdauser_aliases: return False, _("You reached the maximum number of alias that" " you are allowed to create yourself (%s). " % max_lambdauser_aliases) @@ -1695,7 +1692,7 @@ class Service(RevMixin, AclMixin, models.Model): def ask_regen(self): """ Marque à True la demande de régénération pour un service x """ - Service_link.objects.filter(service=self).exclude(asked_regen=True)\ + Service_link.objects.filter(service=self).exclude(asked_regen=True) \ .update(asked_regen=True) return @@ -1703,11 +1700,11 @@ class Service(RevMixin, AclMixin, models.Model): """ Django ne peut créer lui meme les relations manytomany avec table intermediaire explicite""" for serv in servers.exclude( - pk__in=Interface.objects.filter(service=self) + pk__in=Interface.objects.filter(service=self) ): link = Service_link(service=self, server=serv) link.save() - Service_link.objects.filter(service=self).exclude(server__in=servers)\ + Service_link.objects.filter(service=self).exclude(server__in=servers) \ .delete() return @@ -1754,10 +1751,10 @@ class Service_link(RevMixin, AclMixin, models.Model): régénération de service""" return bool( (self.asked_regen and ( - self.last_regen + self.service.min_time_regen + self.last_regen + self.service.min_time_regen ) < timezone.now() - ) or ( - self.last_regen + self.service.regular_time_regen + ) or ( + self.last_regen + self.service.regular_time_regen ) < timezone.now() ) @@ -1875,9 +1872,8 @@ class OuverturePort(RevMixin, AclMixin, models.Model): ), default=OUT, ) - + class Meta: - verbose_name = _("ports opening") verbose_name = _("ports openings") def __str__(self): @@ -2044,4 +2040,3 @@ def srv_post_save(**_kwargs): def srv_post_delete(**_kwargs): """Regeneration dns après modification d'un SRV""" regen('dns') - diff --git a/machines/serializers.py b/machines/serializers.py index f3a47c55..3f5fb966 100644 --- a/machines/serializers.py +++ b/machines/serializers.py @@ -26,8 +26,8 @@ Serializers for the Machines app """ - from rest_framework import serializers + from machines.models import ( Interface, IpType, @@ -148,13 +148,13 @@ class TypeSerializer(serializers.ModelSerializer): get ForeignKey values. Infos about the general port policy is added """ extension = ExtensionNameField(read_only=True) - ouverture_ports_tcp_in = serializers\ + ouverture_ports_tcp_in = serializers \ .SerializerMethodField('get_port_policy_input_tcp') - ouverture_ports_tcp_out = serializers\ + ouverture_ports_tcp_out = serializers \ .SerializerMethodField('get_port_policy_output_tcp') - ouverture_ports_udp_in = serializers\ + ouverture_ports_udp_in = serializers \ .SerializerMethodField('get_port_policy_input_udp') - ouverture_ports_udp_out = serializers\ + ouverture_ports_udp_out = serializers \ .SerializerMethodField('get_port_policy_output_udp') class Meta: @@ -400,7 +400,7 @@ class OuverturePortsSerializer(serializers.Serializer): return { i.ipv4.ipv4: { "tcp_in": [j.tcp_ports_in() for j in i.port_lists.all()], - "tcp_out": [j.tcp_ports_out()for j in i.port_lists.all()], + "tcp_out": [j.tcp_ports_out() for j in i.port_lists.all()], "udp_in": [j.udp_ports_in() for j in i.port_lists.all()], "udp_out": [j.udp_ports_out() for j in i.port_lists.all()], } @@ -413,7 +413,7 @@ class OuverturePortsSerializer(serializers.Serializer): return { i.ipv6: { "tcp_in": [j.tcp_ports_in() for j in i.port_lists.all()], - "tcp_out": [j.tcp_ports_out()for j in i.port_lists.all()], + "tcp_out": [j.tcp_ports_out() for j in i.port_lists.all()], "udp_in": [j.udp_ports_in() for j in i.port_lists.all()], "udp_out": [j.udp_ports_out() for j in i.port_lists.all()], } diff --git a/machines/urls.py b/machines/urls.py index d6f3a541..77fb5e2e 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -27,6 +27,7 @@ The defined URLs for the Machines app from __future__ import unicode_literals from django.conf.urls import url + from . import views urlpatterns = [ diff --git a/machines/views.py b/machines/views.py index 02c3c671..8d395749 100644 --- a/machines/views.py +++ b/machines/views.py @@ -32,26 +32,18 @@ The views for the Machines app from __future__ import unicode_literals -from django.urls import reverse -from django.http import HttpResponse, HttpResponseRedirect -from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required from django.db.models import ProtectedError, F from django.forms import modelformset_factory -from django.views.decorators.csrf import csrf_exempt +from django.http import HttpResponse +from django.shortcuts import render, redirect +from django.urls import reverse from django.utils.translation import ugettext as _ - +from django.views.decorators.csrf import csrf_exempt from rest_framework.renderers import JSONRenderer -from users.models import User from preferences.models import GeneralOption -from re2o.utils import ( - all_active_assigned_interfaces, - filter_active_interfaces, - SortTable, - re2o_paginator, -) from re2o.acl import ( can_create, can_edit, @@ -60,21 +52,14 @@ from re2o.acl import ( can_view_all, can_delete_set, ) -from re2o.views import form - -from .serializers import ( - FullInterfaceSerializer, - InterfaceSerializer, - TypeSerializer, - DomainSerializer, - TxtSerializer, - SrvSerializer, - MxSerializer, - ExtensionSerializer, - ServiceServersSerializer, - NsSerializer, +from re2o.utils import ( + all_active_assigned_interfaces, + filter_active_interfaces, + SortTable, + re2o_paginator, ) - +from re2o.views import form +from users.models import User from .forms import ( NewMachineForm, EditMachineForm, @@ -139,6 +124,18 @@ from .models import ( OuverturePort, Ipv6List, ) +from .serializers import ( + FullInterfaceSerializer, + InterfaceSerializer, + TypeSerializer, + DomainSerializer, + TxtSerializer, + SrvSerializer, + MxSerializer, + ExtensionSerializer, + ServiceServersSerializer, + NsSerializer, +) def f_type_id(is_type_tt): @@ -153,12 +150,12 @@ def generate_ipv4_choices(form_obj): """ f_ipv4 = form_obj.fields['ipv4'] used_mtype_id = [] - choices = '{"":[{key:"",value:"'+_("Select a machine type first.") + '"}' + choices = '{"":[{key:"",value:"' + _("Select a machine type first.") + '"}' mtype_id = -1 for ip in (f_ipv4.queryset - .annotate(mtype_id=F('ip_type__machinetype__id')) - .order_by('mtype_id', 'id')): + .annotate(mtype_id=F('ip_type__machinetype__id')) + .order_by('mtype_id', 'id')): if mtype_id != ip.mtype_id: mtype_id = ip.mtype_id used_mtype_id.append(mtype_id) @@ -172,7 +169,7 @@ def generate_ipv4_choices(form_obj): ) for t in form_obj.fields['type'].queryset.exclude(id__in=used_mtype_id): - choices += '], "'+str(t.id)+'": [' + choices += '], "' + str(t.id) + '": [' choices += '{key: "", value: "' + str(f_ipv4.empty_label) + '"},' choices += ']}' return choices @@ -889,6 +886,7 @@ def del_ns(request, instances): request ) + @login_required @can_create(DName) def add_dname(request): @@ -935,9 +933,9 @@ def del_dname(request, instances): messages.success(request, _("The DNAME record was deleted.")) except ProtectedError: messages.error( - request, - _("Error: the DNAME record %s can't be deleted.") - % dname_del + request, + _("Error: the DNAME record %s can't be deleted.") + % dname_del ) return redirect(reverse('machines:index-extension')) return form( @@ -1252,16 +1250,16 @@ def del_service(request, instances): request ) + @login_required @can_edit(Service) -def regen_service(request,service, **_kwargs): +def regen_service(request, service, **_kwargs): """Ask for a regen of the service""" regen(service) return index_service(request) - @login_required @can_create(Vlan) def add_vlan(request): @@ -1388,10 +1386,10 @@ def index(request): .prefetch_related('interface_set__domain__extension') .prefetch_related('interface_set__ipv4__ip_type') .prefetch_related( - 'interface_set__type__ip_type__extension' - ).prefetch_related( - 'interface_set__domain__related_domain__extension' - ).prefetch_related('interface_set__ipv6list')) + 'interface_set__type__ip_type__extension' + ).prefetch_related( + 'interface_set__domain__related_domain__extension' + ).prefetch_related('interface_set__ipv6list')) machines_list = SortTable.sort( machines_list, request.GET.get('col'), @@ -1548,8 +1546,8 @@ def index_role(request): """ View used to display the list of existing roles """ role_list = (Role.objects .prefetch_related( - 'servers__domain__extension' - ).all()) + 'servers__domain__extension' + ).all()) return render( request, 'machines/index_role.html', @@ -1563,8 +1561,8 @@ def index_service(request): """ View used to display the list of existing services """ service_list = (Service.objects .prefetch_related( - 'service_link_set__server__domain__extension' - ).all()) + 'service_link_set__server__domain__extension' + ).all()) servers_list = (Service_link.objects .select_related('server__domain__extension') .select_related('service') @@ -1740,10 +1738,10 @@ def alias(_request): alias = (Domain.objects .filter(interface_parent=None) .filter( - cname__in=Domain.objects.filter( - interface_parent__in=Interface.objects.exclude(ipv4=None) - ) - ).select_related('extension') + cname__in=Domain.objects.filter( + interface_parent__in=Interface.objects.exclude(ipv4=None) + ) + ).select_related('extension') .select_related('cname__extension')) seria = DomainSerializer(alias, many=True) return JSONResponse(seria.data) @@ -1801,10 +1799,10 @@ def ns(_request): """ API view to list the NS records """ ns = (Ns.objects .exclude( - ns__in=Domain.objects.filter( - interface_parent__in=Interface.objects.filter(ipv4=None) - ) - ).select_related('zone') + ns__in=Domain.objects.filter( + interface_parent__in=Interface.objects.filter(ipv4=None) + ) + ).select_related('zone') .select_related('ns__extension')) seria = NsSerializer(ns, many=True) return JSONResponse(seria.data) @@ -1859,9 +1857,9 @@ def ouverture_ports(_request): """ API view to list the port policies for each IP """ r = {'ipv4': {}, 'ipv6': {}} for o in (OuverturePortList.objects - .all() - .prefetch_related('ouvertureport_set') - .prefetch_related('interface_set', 'interface_set__ipv4')): + .all() + .prefetch_related('ouvertureport_set') + .prefetch_related('interface_set', 'interface_set__ipv4')): pl = { "tcp_in": set(map( str, @@ -1926,17 +1924,16 @@ def regen_achieved(request): """ API view to list the regen status for each (Service link, Server) couple """ obj = (Service_link.objects - .filter( - service__in=Service.objects.filter( - service_type=request.POST['service'] - ), - server__in=Interface.objects.filter( - domain__in=Domain.objects.filter( - name=request.POST['server'] - ) - ) - )) + .filter( + service__in=Service.objects.filter( + service_type=request.POST['service'] + ), + server__in=Interface.objects.filter( + domain__in=Domain.objects.filter( + name=request.POST['server'] + ) + ) + )) if obj: obj.first().done_regen() return HttpResponse("Ok") -