mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	Apply suggestions from code review
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
		| @@ -162,9 +162,8 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin): | ||||
|         table = self.get_table(self.queryset, request, has_bulk_actions) | ||||
|  | ||||
|         # Check for filterset_form on this view, if a form exists, apply to context and table, otherwise set to None | ||||
|         filterset_form = None | ||||
|         if hasattr(self, 'filterset_form') and self.filterset_form: | ||||
|             filterset_form = self.filterset_form(request.GET, label_suffix='') | ||||
|         if self.filterset_form: | ||||
|             filterset_form = self.filterset_form(request.GET) | ||||
|             table.filterset_form = filterset_form | ||||
|  | ||||
|         # If this is an HTMX request, return only the rendered table HTML | ||||
|   | ||||
| @@ -1,7 +1,8 @@ | ||||
| {% load form_helpers %} | ||||
| {% if form_field %} | ||||
| <div class="column-filter dropdown"> | ||||
|     <a href="#" classs="btn dropdown-toggle" data-bs-toggle="dropdown" data-bs-auto-close="outside"> | ||||
|     <a href="#" class="btn dropdown-toggle" data-bs-toggle="dropdown" data-bs-auto-close="outside"> | ||||
|  | ||||
|         <i class="mdi mdi-filter-settings" style="font-size: 1.25rem;"> </i> | ||||
|     </a> | ||||
|     <div class="dropdown-menu"> | ||||
|   | ||||
| @@ -17,8 +17,8 @@ | ||||
|                   ><i class="mdi mdi-close"></i></a> | ||||
|                 </div> | ||||
|               {% endif %} | ||||
|               {%  if table.filterset_form %} | ||||
|                 {% include 'inc/table_header_filter_dropdown.html' with form_field=table.filterset_form|getfilterfield:column.name %} | ||||
|               {% if table.filterset_form %} | ||||
|                 {% include 'inc/table_header_filter_dropdown.html' with form_field=table.filterset_form|get_filter_field:column.name %} | ||||
|               {% endif %} | ||||
|               <a href="#" | ||||
|                  hx-get="{{ table.htmx_url }}{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}" | ||||
| @@ -28,8 +28,8 @@ | ||||
|             </th> | ||||
|           {% else %} | ||||
|             <th {{ column.attrs.th.as_html }}> | ||||
|               {%  if table.filterset_form %} | ||||
|                 {% include 'inc/table_header_filter_dropdown.html' with form_field=table.filterset_form|getfilterfield:column.name %} | ||||
|               {% if table.filterset_form %} | ||||
|                 {% include 'inc/table_header_filter_dropdown.html' with form_field=table.filterset_form|get_filter_field:column.name %} | ||||
|               {% endif %} | ||||
|               {{ column.header }} | ||||
|             </th> | ||||
|   | ||||
| @@ -6,7 +6,7 @@ from utilities.forms.rendering import FieldSet, InlineFields, ObjectAttribute, T | ||||
|  | ||||
| __all__ = ( | ||||
|     'getfield', | ||||
|     'getfilterfield', | ||||
|     'get_filter_field', | ||||
|     'render_custom_fields', | ||||
|     'render_errors', | ||||
|     'render_field', | ||||
| @@ -35,7 +35,7 @@ def getfield(form, fieldname): | ||||
|  | ||||
|  | ||||
| @register.filter() | ||||
| def getfilterfield(form, fieldname): | ||||
| def get_filter_field(form, fieldname): | ||||
|     field = getfield(form, f'{fieldname}') | ||||
|     if field is not None: | ||||
|         return field | ||||
|   | ||||
		Reference in New Issue
	
	Block a user