diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py index 7e2ce017b46..562713f5b11 100644 --- a/netbox/ipam/tables.py +++ b/netbox/ipam/tables.py @@ -70,9 +70,9 @@ {% if record.pk %} {{ record.address }} {% elif perms.ipam.add_ipaddress %} - {% if record.0 <= 65536 %}{{ record.0 }}{% else %}Lots of{% endif %} free IP{{ record.0|pluralize }} + {% if record.0 <= 65536 %}{{ record.0 }}{% else %}Many{% endif %} IP{{ record.0|pluralize }} available {% else %} - {{ record.0 }} + {% if record.0 <= 65536 %}{{ record.0 }}{% else %}Many{% endif %} IP{{ record.0|pluralize }} available {% endif %} """ diff --git a/netbox/templates/circuits/circuit_import.html b/netbox/templates/circuits/circuit_import.html index 991a99c9b38..4b0c40b093f 100644 --- a/netbox/templates/circuits/circuit_import.html +++ b/netbox/templates/circuits/circuit_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Circuit Import{% endblock %} diff --git a/netbox/templates/circuits/provider_import.html b/netbox/templates/circuits/provider_import.html index e60ee3e76f2..2ab2e5efb6e 100644 --- a/netbox/templates/circuits/provider_import.html +++ b/netbox/templates/circuits/provider_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Provider Import{% endblock %} diff --git a/netbox/templates/dcim/console_connections_import.html b/netbox/templates/dcim/console_connections_import.html index c7308168b2e..3dc0f96a4dd 100644 --- a/netbox/templates/dcim/console_connections_import.html +++ b/netbox/templates/dcim/console_connections_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Console Connections Import{% endblock %} diff --git a/netbox/templates/dcim/console_connections_list.html b/netbox/templates/dcim/console_connections_list.html index 68b57dc2726..fc2cbb7627e 100644 --- a/netbox/templates/dcim/console_connections_list.html +++ b/netbox/templates/dcim/console_connections_list.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}Console Connections{% endblock %} @@ -16,7 +15,7 @@

Console Connections

- {% render_table table 'table.html' %} + {% include 'responsive_table.html' %}
{% include 'inc/search_panel.html' %} diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 02738da1fda..bafcdd22482 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -1,6 +1,5 @@ {% extends '_base.html' %} {% load static from staticfiles %} -{% load render_table from django_tables2 %} {% load helpers %} {% block title %}{{ device }}{% endblock %} diff --git a/netbox/templates/dcim/device_import.html b/netbox/templates/dcim/device_import.html index df456ee985e..8a1cfa1a56f 100644 --- a/netbox/templates/dcim/device_import.html +++ b/netbox/templates/dcim/device_import.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Device Import{% endblock %} diff --git a/netbox/templates/dcim/device_import_child.html b/netbox/templates/dcim/device_import_child.html index 49433686fdf..3fea2572a8e 100644 --- a/netbox/templates/dcim/device_import_child.html +++ b/netbox/templates/dcim/device_import_child.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Device Import{% endblock %} diff --git a/netbox/templates/dcim/devicetype.html b/netbox/templates/dcim/devicetype.html index a9a9fa13071..365ba2057f8 100644 --- a/netbox/templates/dcim/devicetype.html +++ b/netbox/templates/dcim/devicetype.html @@ -1,6 +1,5 @@ {% extends '_base.html' %} {% load helpers %} -{% load render_table from django_tables2 %} {% block title %}{{ devicetype.manufacturer }} {{ devicetype.model }}{% endblock %} diff --git a/netbox/templates/dcim/inc/devicetype_component_table.html b/netbox/templates/dcim/inc/devicetype_component_table.html index 00ed12b5ad5..fa10948a697 100644 --- a/netbox/templates/dcim/inc/devicetype_component_table.html +++ b/netbox/templates/dcim/inc/devicetype_component_table.html @@ -1,4 +1,3 @@ -{% load render_table from django_tables2 %} {% if perms.dcim.change_devicetype %}
{% csrf_token %} @@ -19,7 +18,7 @@ {% endif %}
- {% render_table table 'table.html' %} + {% include 'responsive_table.html' %} {% endif %} diff --git a/netbox/templates/dcim/interface_connections_import.html b/netbox/templates/dcim/interface_connections_import.html index eab0acdbaf1..4cfd82e5879 100644 --- a/netbox/templates/dcim/interface_connections_import.html +++ b/netbox/templates/dcim/interface_connections_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Interface Connections Import{% endblock %} diff --git a/netbox/templates/dcim/interface_connections_list.html b/netbox/templates/dcim/interface_connections_list.html index 23c7b8a9a91..a37028624a6 100644 --- a/netbox/templates/dcim/interface_connections_list.html +++ b/netbox/templates/dcim/interface_connections_list.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}Interface Connections{% endblock %} @@ -16,7 +15,7 @@

Interface Connections

- {% render_table table 'table.html' %} + {% include 'responsive_table.html' %}
{% include 'inc/search_panel.html' %} diff --git a/netbox/templates/dcim/power_connections_import.html b/netbox/templates/dcim/power_connections_import.html index 56f34c4560d..bd60834daf7 100644 --- a/netbox/templates/dcim/power_connections_import.html +++ b/netbox/templates/dcim/power_connections_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Power Connections Import{% endblock %} diff --git a/netbox/templates/dcim/power_connections_list.html b/netbox/templates/dcim/power_connections_list.html index 1b6528d861f..79001fe408b 100644 --- a/netbox/templates/dcim/power_connections_list.html +++ b/netbox/templates/dcim/power_connections_list.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}Power Connections{% endblock %} @@ -16,7 +15,7 @@

Power Connections

- {% render_table table 'table.html' %} + {% include 'responsive_table.html' %}
{% include 'inc/search_panel.html' %} diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index 26e9c4988b6..d0132055288 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -1,6 +1,5 @@ {% extends '_base.html' %} {% load helpers %} -{% load render_table from django_tables2 %} {% block title %}{{ rack.site }} - Rack {{ rack.name }}{% endblock %} diff --git a/netbox/templates/dcim/rack_elevation_list.html b/netbox/templates/dcim/rack_elevation_list.html index 00496a0d0e9..c5c060940f4 100644 --- a/netbox/templates/dcim/rack_elevation_list.html +++ b/netbox/templates/dcim/rack_elevation_list.html @@ -11,24 +11,25 @@

{% block title %}Rack Elevations{% endblock %}

{% if page %}
- {% for rack in page %} -
-
-

{{ rack.name }}

+ {% for rack in page %} +
+ + {% if face_id %} + {% include 'dcim/inc/rack_elevation.html' with primary_face=rack.get_rear_elevation secondary_face=rack.get_front_elevation face_id=1 %} + {% else %} + {% include 'dcim/inc/rack_elevation.html' with primary_face=rack.get_front_elevation secondary_face=rack.get_rear_elevation face_id=0 %} + {% endif %} +
+
- {% if face_id %} - {% include 'dcim/inc/rack_elevation.html' with primary_face=rack.get_rear_elevation secondary_face=rack.get_front_elevation face_id=1 %} - {% else %} - {% include 'dcim/inc/rack_elevation.html' with primary_face=rack.get_front_elevation secondary_face=rack.get_rear_elevation face_id=0 %} - {% endif %} -
- -
- {% endfor %} + {% endfor %}
- {% include 'paginator.html' %} +
+ {% include 'inc/paginator.html' %}
{% else %}
diff --git a/netbox/templates/dcim/rack_import.html b/netbox/templates/dcim/rack_import.html index 207fcfcab90..e3e40c5cd96 100644 --- a/netbox/templates/dcim/rack_import.html +++ b/netbox/templates/dcim/rack_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Rack Import{% endblock %} diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html index b1d0fb19421..f86565bf849 100644 --- a/netbox/templates/dcim/site.html +++ b/netbox/templates/dcim/site.html @@ -1,6 +1,5 @@ {% extends '_base.html' %} {% load static from staticfiles %} -{% load render_table from django_tables2 %} {% load helpers %} {% block title %}{{ site }}{% endblock %} diff --git a/netbox/templates/dcim/site_import.html b/netbox/templates/dcim/site_import.html index a7ac47ab58a..3a4e6277a35 100644 --- a/netbox/templates/dcim/site_import.html +++ b/netbox/templates/dcim/site_import.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Site Import{% endblock %} diff --git a/netbox/templates/home.html b/netbox/templates/home.html index b657bf5983b..f553ed9c870 100644 --- a/netbox/templates/home.html +++ b/netbox/templates/home.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block content %} {% include 'search_form.html' %} diff --git a/netbox/templates/import_success.html b/netbox/templates/import_success.html index 04c454e1d0f..00aadfea739 100644 --- a/netbox/templates/import_success.html +++ b/netbox/templates/import_success.html @@ -1,9 +1,8 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block content %}

{% block title %}Import Completed{% endblock %}

- {% render_table table %} + {% include 'responsive_table.html' %} Import more diff --git a/netbox/templates/paginator.html b/netbox/templates/inc/paginator.html similarity index 69% rename from netbox/templates/paginator.html rename to netbox/templates/inc/paginator.html index 33d41054251..27d04c15ccb 100644 --- a/netbox/templates/paginator.html +++ b/netbox/templates/inc/paginator.html @@ -1,11 +1,11 @@ {% load helpers %} -
+
{% if paginator.num_pages > 1 %} {% endif %} -
-
- Showing {{ page.start_index }}-{{ page.end_index }} of {{ total_count }} -
+ {% if page %} +
+ Showing {{ page.start_index }}-{{ page.end_index }} of {{ page.paginator.count }} +
+ {% endif %}
diff --git a/netbox/templates/inc/table.html b/netbox/templates/inc/table.html new file mode 100644 index 00000000000..e8d84fbebe0 --- /dev/null +++ b/netbox/templates/inc/table.html @@ -0,0 +1,41 @@ +{% load django_tables2 %} + + + {% if table.show_header %} + + + {% for column in table.columns %} + {% if column.orderable %} + {{ column.header }} + {% else %} + {{ column.header }} + {% endif %} + {% endfor %} + + + {% endif %} + + {% for row in table.page.object_list|default:table.rows %} + + {% for column, cell in row.items %} + {{ cell }} + {% endfor %} + + {% empty %} + {% if table.empty_text %} + + {{ table.empty_text }} + + {% endif %} + {% endfor %} + + {% if table.has_footer %} + + + {% for column in table.columns %} + {{ column.footer }} + {% endfor %} + + + {% endif %} + diff --git a/netbox/templates/ipam/aggregate.html b/netbox/templates/ipam/aggregate.html index b814ea25be2..bd5801f0eb2 100644 --- a/netbox/templates/ipam/aggregate.html +++ b/netbox/templates/ipam/aggregate.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}Aggregate: {{ aggregate }}{% endblock %} diff --git a/netbox/templates/ipam/aggregate_import.html b/netbox/templates/ipam/aggregate_import.html index 1f0a50febc1..1a270e450af 100644 --- a/netbox/templates/ipam/aggregate_import.html +++ b/netbox/templates/ipam/aggregate_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Aggregate Import{% endblock %} diff --git a/netbox/templates/ipam/ipaddress.html b/netbox/templates/ipam/ipaddress.html index 357ea5dac9d..e6dd489df51 100644 --- a/netbox/templates/ipam/ipaddress.html +++ b/netbox/templates/ipam/ipaddress.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}{{ ipaddress }}{% endblock %} @@ -133,17 +132,11 @@

{{ ipaddress }}

{% endwith %}
- {% with heading='Parent Prefixes' %} - {% render_table parent_prefixes_table 'panel_table.html' %} - {% endwith %} + {% include 'panel_table.html' with table=parent_prefixes_table heading='Parent Prefixes' %} {% if duplicate_ips_table.rows %} - {% with heading='Duplicate IP Addresses' panel_class='danger' %} - {% render_table duplicate_ips_table 'panel_table.html' %} - {% endwith %} + {% include 'panel_table.html' with table=duplicate_ips_table heading='Duplicate IP Addresses' panel_class='danger' %} {% endif %} - {% with heading='Related IP Addresses' %} - {% render_table related_ips_table 'panel_table.html' %} - {% endwith %} + {% include 'panel_table.html' with table=related_ips_table heading='Related IP Addresses' %}
{% endblock %} diff --git a/netbox/templates/ipam/ipaddress_import.html b/netbox/templates/ipam/ipaddress_import.html index 362f6482908..9193a207dc7 100644 --- a/netbox/templates/ipam/ipaddress_import.html +++ b/netbox/templates/ipam/ipaddress_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}IP Address Import{% endblock %} diff --git a/netbox/templates/ipam/prefix.html b/netbox/templates/ipam/prefix.html index 9187b81b498..b2b996fce22 100644 --- a/netbox/templates/ipam/prefix.html +++ b/netbox/templates/ipam/prefix.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}{{ prefix }}{% endblock %} @@ -134,13 +133,9 @@
{% if duplicate_prefix_table.rows %} - {% with heading='Duplicate Prefixes' panel_class='danger' %} - {% render_table duplicate_prefix_table 'panel_table.html' %} - {% endwith %} + {% include 'panel_table.html' with table=duplicate_prefix_table heading='Duplicate Prefixes' panel_class='danger' %} {% endif %} - {% with heading='Parent Prefixes' %} - {% render_table parent_prefix_table 'panel_table.html' %} - {% endwith %} + {% include 'panel_table.html' with table=parent_prefix_table heading='Parent Prefixes' %}
diff --git a/netbox/templates/ipam/prefix_import.html b/netbox/templates/ipam/prefix_import.html index b9aa7ff4728..a135fcb31bf 100644 --- a/netbox/templates/ipam/prefix_import.html +++ b/netbox/templates/ipam/prefix_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Prefix Import{% endblock %} diff --git a/netbox/templates/ipam/prefix_ipaddresses.html b/netbox/templates/ipam/prefix_ipaddresses.html index 621bb2f22f4..a3554da39e9 100644 --- a/netbox/templates/ipam/prefix_ipaddresses.html +++ b/netbox/templates/ipam/prefix_ipaddresses.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}{{ prefix }}{% endblock %} diff --git a/netbox/templates/ipam/vlan.html b/netbox/templates/ipam/vlan.html index 6c1fb07d230..0401e75cb5e 100644 --- a/netbox/templates/ipam/vlan.html +++ b/netbox/templates/ipam/vlan.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% block title %}VLAN {{ vlan.display_name }}{% endblock %} @@ -136,7 +135,7 @@

VLAN {{ vlan.display_name }}

Prefixes
- {% render_table prefix_table %} + {% include 'responsive_table.html' with table=prefix_table %} {% if perms.ipam.add_prefix %}
diff --git a/netbox/templates/ipam/vrf_import.html b/netbox/templates/ipam/vrf_import.html index 0a1a31205f3..5c7821e5320 100644 --- a/netbox/templates/ipam/vrf_import.html +++ b/netbox/templates/ipam/vrf_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}VRF Import{% endblock %} diff --git a/netbox/templates/panel_table.html b/netbox/templates/panel_table.html index 0df5020cbbd..208e98a88ce 100644 --- a/netbox/templates/panel_table.html +++ b/netbox/templates/panel_table.html @@ -1,10 +1,5 @@ -{% extends 'django_tables2/table.html' %} -{% load django_tables2 %} -{% load i18n %} +{% load render_table from django_tables2 %} -{# Wraps a table inside a Bootstrap panel and includes custom pagination rendering #} - -{% block table %}
{% if heading %}
@@ -12,15 +7,14 @@
{% endif %} {% if table.rows %} - {{ block.super }} + {% render_table table 'inc/table.html' %} {% else %}
None
{% endif %}
-{% endblock %} -{% block pagination %} - {% if not hide_paginator %} - {% include 'table_paginator.html' %} - {% endif %} -{% endblock pagination %} +{% if table.rows %} + {% with paginator=table.paginator page=table.page %} + {% include 'inc/paginator.html' %} + {% endwith %} +{% endif %} diff --git a/netbox/templates/responsive_table.html b/netbox/templates/responsive_table.html new file mode 100644 index 00000000000..81d9126fda2 --- /dev/null +++ b/netbox/templates/responsive_table.html @@ -0,0 +1,8 @@ +{% load render_table from django_tables2 %} + +
+ {% render_table table 'inc/table.html' %} +
+{% with paginator=table.paginator page=table.page %} + {% include 'inc/paginator.html' %} +{% endwith %} diff --git a/netbox/templates/secrets/secret_import.html b/netbox/templates/secrets/secret_import.html index 73daf72d982..edc308d06d8 100644 --- a/netbox/templates/secrets/secret_import.html +++ b/netbox/templates/secrets/secret_import.html @@ -1,6 +1,5 @@ {% extends '_base.html' %} {% load static from staticfiles %} -{% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Secret Import{% endblock %} diff --git a/netbox/templates/table.html b/netbox/templates/table.html deleted file mode 100644 index 6da4a91e42f..00000000000 --- a/netbox/templates/table.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends 'django_tables2/bootstrap-responsive.html' %} -{% load django_tables2 %} - -{# Extends the stock django_tables2 template to provide custom formatting of the pagination controls #} - -{% block pagination %} - {% if not hide_paginator %} - {% include 'table_paginator.html' %} - {% endif %} -{% endblock pagination %} diff --git a/netbox/templates/table_paginator.html b/netbox/templates/table_paginator.html deleted file mode 100644 index 90bd41473b3..00000000000 --- a/netbox/templates/table_paginator.html +++ /dev/null @@ -1,36 +0,0 @@ -{% load django_tables2 %} - -{# Custom pagination controls to render nicely with Bootstrap CSS. smart_pages requires EnhancedPaginator. #} - -
- {% if table.paginator.num_pages > 1 %} - - {% endif %} -
-
- {% with table.page.paginator.count as total %} - Showing {{ table.page.start_index }}-{{ table.page.end_index }} of {{ total }} - {% if total == 1 %} - {{ table.data.verbose_name }} - {% else %} - {{ table.data.verbose_name_plural }} - {% endif %} - {% endwith %} -
-
diff --git a/netbox/templates/tenancy/tenant_import.html b/netbox/templates/tenancy/tenant_import.html index c0e94269a7f..2e5196a88ee 100644 --- a/netbox/templates/tenancy/tenant_import.html +++ b/netbox/templates/tenancy/tenant_import.html @@ -1,6 +1,4 @@ {% extends 'utilities/obj_import.html' %} -{% load render_table from django_tables2 %} -{% load form_helpers %} {% block title %}Tenant Import{% endblock %} diff --git a/netbox/templates/utilities/obj_import.html b/netbox/templates/utilities/obj_import.html index bea9a231977..2d69be048eb 100644 --- a/netbox/templates/utilities/obj_import.html +++ b/netbox/templates/utilities/obj_import.html @@ -1,5 +1,4 @@ {% extends '_base.html' %} -{% load render_table from django_tables2 %} {% load form_helpers %} {% block content %} diff --git a/netbox/templates/utilities/obj_table.html b/netbox/templates/utilities/obj_table.html index 7f237632d85..a5777322216 100644 --- a/netbox/templates/utilities/obj_table.html +++ b/netbox/templates/utilities/obj_table.html @@ -1,4 +1,3 @@ -{% load render_table from django_tables2 %} {% load helpers %} {% if permissions.change or permissions.delete %} @@ -28,7 +27,7 @@
{% endif %} - {% render_table table table_template|default:'table.html' %} + {% include table_template|default:'responsive_table.html' %} {% block extra_actions %}{% endblock %} {% if bulk_edit_url and permissions.change %}