diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index a489fdbfa..210b8a27c 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -2541,6 +2541,7 @@ class ConsoleConnectionsListView(generic.ObjectListView): filterset_form = forms.ConsoleConnectionFilterForm table = tables.ConsoleConnectionTable template_name = 'dcim/connections_list.html' + action_buttons = ('export',) def extra_context(self): return { @@ -2554,6 +2555,7 @@ class PowerConnectionsListView(generic.ObjectListView): filterset_form = forms.PowerConnectionFilterForm table = tables.PowerConnectionTable template_name = 'dcim/connections_list.html' + action_buttons = ('export',) def extra_context(self): return { @@ -2567,6 +2569,7 @@ class InterfaceConnectionsListView(generic.ObjectListView): filterset_form = forms.InterfaceConnectionFilterForm table = tables.InterfaceConnectionTable template_name = 'dcim/connections_list.html' + action_buttons = ('export',) def extra_context(self): return { diff --git a/netbox/extras/forms.py b/netbox/extras/forms.py index 98f34dfa9..18398a4fd 100644 --- a/netbox/extras/forms.py +++ b/netbox/extras/forms.py @@ -519,12 +519,14 @@ class CustomFieldModelFilterForm(forms.Form): super().__init__(*args, **kwargs) # Add all applicable CustomFields to the form + self.custom_field_filters = [] custom_fields = CustomField.objects.filter(content_types=self.obj_type).exclude( filter_logic=CustomFieldFilterLogicChoices.FILTER_DISABLED ) for cf in custom_fields: field_name = 'cf_{}'.format(cf.name) self.fields[field_name] = cf.to_form_field(set_initial=True, enforce_required=False) + self.custom_field_filters.append(field_name) # diff --git a/netbox/templates/dcim/connections_list.html b/netbox/templates/dcim/connections_list.html index cfe17d62f..5dbea9129 100644 --- a/netbox/templates/dcim/connections_list.html +++ b/netbox/templates/dcim/connections_list.html @@ -1,24 +1,34 @@ -{% extends 'base/layout.html' %} +{% extends 'generic/object_list.html' %} {% load buttons %} +{% load helpers %} {% load render_table from django_tables2 %} {% block title %}{{ title }}{% endblock %} -{% block extra_controls %}{% export_button content_type %}{% endblock %} +{% block content-wrapper %} +
-{% block content %} -
-
- {% include 'inc/table_controls.html' %} + {# Conncetions list #} +
+ {% include 'inc/table_controls.html' %} -
- {% render_table table 'inc/table.html' %} -
- - {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %} +
+
+
+ {% render_table table 'inc/table.html' %} +
- {% if filter_form %} - {% include 'inc/filter_list.html' %} - {% endif %} +
+ + {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
-{% endblock %} + + {# Filter form #} + {% if filter_form %} +
+ {% include 'inc/filter_list.html' %} +
+ {% endif %} + +
+{% endblock content-wrapper %} diff --git a/netbox/templates/dcim/rack_elevation_list.html b/netbox/templates/dcim/rack_elevation_list.html index c9f0080da..522bac60e 100644 --- a/netbox/templates/dcim/rack_elevation_list.html +++ b/netbox/templates/dcim/rack_elevation_list.html @@ -1,4 +1,4 @@ -{% extends 'base/layout.html' %} +{% extends 'generic/object_list.html' %} {% load helpers %} {% load static %} @@ -22,41 +22,50 @@
{% endblock %} -{% block content %} -
-
- {% if page %} -
- {% for rack in page %} -
-
-
- {{ rack.name }} - {% if rack.role %} -
{{ rack.role }} - {% endif %} - {% if rack.facility_id %} -
{{ rack.facility_id }} - {% endif %} -
- {% include 'dcim/inc/rack_elevation.html' with object=rack face=rack_face %} -
-
- {{ rack.name }} - {% if rack.facility_id %} - ({{ rack.facility_id }}) - {% endif %} -
-
-
- {% endfor %} -
-
- {% include 'inc/paginator.html' %} - {% else %} -

No Racks Found

- {% endif %} -
- {% include 'inc/filter_list.html' %} +{% block content-wrapper %} +
+ + {# Rack elevations #} +
+ {% if page %} +
+ {% for rack in page %} +
+
+
+ {{ rack.name }} + {% if rack.role %} +
{{ rack.role }} + {% endif %} + {% if rack.facility_id %} +
{{ rack.facility_id }} + {% endif %} +
+ {% include 'dcim/inc/rack_elevation.html' with object=rack face=rack_face %} +
+
+ {{ rack.name }} + {% if rack.facility_id %} + ({{ rack.facility_id }}) + {% endif %} +
+
+
+ {% endfor %} +
+
+ {% include 'inc/paginator.html' %} + {% else %} +

No Racks Found

+ {% endif %}
-{% endblock %} + + {# Filter form #} + {% if filter_form %} +
+ {% include 'inc/filter_list.html' %} +
+ {% endif %} + +
+{% endblock content-wrapper %} diff --git a/netbox/templates/generic/object_list.html b/netbox/templates/generic/object_list.html index 2baabb623..e2552c7c8 100644 --- a/netbox/templates/generic/object_list.html +++ b/netbox/templates/generic/object_list.html @@ -4,97 +4,132 @@ {% load render_table from django_tables2 %} {% load static %} -{% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %} - {% block controls %} -
-
- {% block extra_controls %}{% endblock %} - {% if permissions.add and 'add' in action_buttons %} - {% add_button content_type.model_class|validated_viewname:"add" %} - {% endif %} - {% if permissions.add and 'import' in action_buttons %} - {% import_button content_type.model_class|validated_viewname:"import" %} - {% endif %} - {% if 'export' in action_buttons %} - {% export_button content_type %} - {% endif %} +
+
+ {% block extra_controls %}{% endblock %} + {% if permissions.add and 'add' in action_buttons %} + {% add_button content_type.model_class|validated_viewname:"add" %} + {% endif %} + {% if permissions.add and 'import' in action_buttons %} + {% import_button content_type.model_class|validated_viewname:"import" %} + {% endif %} + {% if 'export' in action_buttons %} + {% export_button content_type %} + {% endif %} +
-
{% endblock controls %} -{% block content %} -{% if table.paginator.num_pages > 1 %} -{% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %} -
-
- {% csrf_token %} -
-
- {% if bulk_edit_url and permissions.change %} - - {% endif %} - {% if bulk_delete_url and permissions.delete %} - - {% endif %} -
-
- - -
-
-
-
-{% endwith %} -{% endif %} +{% block tabs %} + +{% endblock tabs %} -{# Object table #} -
-
- {# Object list filter, table config #} - {% include 'inc/table_controls.html' with table_modal="ObjectTable_config" %} +{% block content-wrapper %} +
- {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %} - {% if permissions.change or permissions.delete %} -
- {% csrf_token %} - -
- {% render_table table 'inc/table.html' %} + {# Object list #} +
+ {% if table.paginator.num_pages > 1 %} + + {# "Select all" form #} + {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %} +
+ + {% csrf_token %} +
+
+ {% if bulk_edit_url and permissions.change %} + + {% endif %} + {% if bulk_delete_url and permissions.delete %} + + {% endif %} +
+
+ + +
+
+
-
-
- {% block bulk_buttons %}{% endblock %} - {% if bulk_edit_url and permissions.change %} - - {% endif %} - {% if bulk_delete_url and permissions.delete %} - - {% endif %} + {% endwith %} + {% endif %} + + {# Object table controls #} + {% include 'inc/table_controls.html' with table_modal="ObjectTable_config" %} + +
+ {% csrf_token %} + + + {# Object table #} +
+
+
+ {% render_table table 'inc/table.html' %}
- - {% else %} -
- {% render_table table 'inc/table.html' %}
- {% endif %} - {% endwith %} - {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %} + + {# Form buttons #} + {% if permissions.change or permissions.delete %} + {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %} +
+
+ {% block bulk_buttons %}{% endblock %} + {% if bulk_edit_url and permissions.change %} + + {% endif %} + {% if bulk_delete_url and permissions.delete %} + + {% endif %} +
+
+ {% endwith %} + {% endif %} + + + + {# Paginator #} + {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %} +
+ + {# Filter form #} + {% if filter_form %} +
+ {% include 'inc/filter_list.html' %} +
+ {% endif %}
- {% if filter_form %} - {% include 'inc/filter_list.html' %} - {% endif %} -
-{% table_config_form table table_name="ObjectTable" %} -{% endblock content %} + + {# Table config form #} + {% table_config_form table table_name="ObjectTable" %} +{% endblock content-wrapper %} diff --git a/netbox/templates/inc/filter_list.html b/netbox/templates/inc/filter_list.html index 8837a75e2..4da03b5cc 100644 --- a/netbox/templates/inc/filter_list.html +++ b/netbox/templates/inc/filter_list.html @@ -1,65 +1,45 @@ {% load form_helpers %} {% load helpers %} -
-
-
-
- Field Filters -
-
- {% for field in filter_form.hidden_fields %} - {{ field }} - {% endfor %} - {% if filter_form.field_groups %} - {% for group in filter_form.field_groups %} -
- {% for name in group %} - {% with field=filter_form|get_item:name %} - {% if field|widget_type == 'checkboxinput' %} -
- - {{ field }} -
- {% else %} -
- - {{ field }} -
- {% endif %} - {% endwith %} - {% endfor %} -
- {% if forloop.counter != filter_form.field_groups|length %} -
- {% endif %} - {% endfor %} - {% else %} - {% for field in filter_form.visible_fields %} -
- {% if field|widget_type == 'checkboxinput' %} -
- - {{ field }} -
- {% else %} -
- - {{ field }} -
- {% endif %} -
- {% endfor %} - {% endif %} -
- -
-
-
+
+
+
+ {% for field in filter_form.hidden_fields %} + {{ field }} + {% endfor %} + {% if filter_form.field_groups %} + {% for group in filter_form.field_groups %} +
+ {% for name in group %} + {% with field=filter_form|get_item:name %} + {% render_field field %} + {% endwith %} + {% endfor %} +
+
+ {% endfor %} + {% for name in filter_form.custom_field_filters %} +
+ {% with field=filter_form|get_item:name %} + {% render_field field %} + {% endwith %} +
+ {% endfor %} + {% else %} + {% for field in filter_form.visible_fields %} +
+ {% render_field field %} +
+ {% endfor %} + {% endif %} +
+ +
+
diff --git a/netbox/templates/inc/table_controls.html b/netbox/templates/inc/table_controls.html index ec46cd535..d110326ce 100644 --- a/netbox/templates/inc/table_controls.html +++ b/netbox/templates/inc/table_controls.html @@ -1,19 +1,4 @@
-
- {% if request.user.is_authenticated and table_modal %} -
- -
- {% endif %} -
+
+ {% if request.user.is_authenticated and table_modal %} + + {% endif %} +