Repository: netbox-community/netbox
Pull request: Fixes #11244: Elevations: Filter badge missing
<!--
    Thank you for your interest in contributing to NetBox! Please note that
    our contribution policy requires that a feature request or bug report be
    approved and assigned prior to opening a pull request. This helps avoid
    waste time and effort on a proposed change that we might not be able to
    accept.

    IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED
    TO YOU, IT WILL BE CLOSED AUTOMATICALLY.

    Please specify your assigned issue number on the line below.
-->
### Fixes: #11244 

<!--
    Please include a summary of the proposed changes below.
-->


Problem statement:
Elevations: Filter badge missing
### NetBox version

v3.4.1

### Python version

3.9

### Steps to Reproduce

1. Go to menu => Elevations
2. Click tab "Filters"
3. Type any search term and press Enter

### Expected Behavior

I would expect a filter badge and a save button to be displayed as in other views. If you have a look at the "Filters" tab you can see that there is a dropdown for "Saved Filter" which doesn't make sense if you are not able to save a filter.

### Observed Behavior

Neither filter badge nor save button is shown.

Hints from issue discussion:
@jeremystretch You can assign this to me if you like.

Commit message: Merge branch 'netbox-community:develop' into 11244_filter_badge_missing

Patch to review:
diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
index 06a48653478..b0e176a9677 100644
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -652,6 +652,7 @@ def get(self, request):
 
         racks = filtersets.RackFilterSet(request.GET, self.queryset).qs
         total_count = racks.count()
+        self.model = self.queryset.model
 
         # Ordering
         ORDERING_CHOICES = {
@@ -691,6 +692,7 @@ def get(self, request):
             'sort_choices': ORDERING_CHOICES,
             'rack_face': rack_face,
             'filter_form': forms.RackElevationFilterForm(request.GET),
+            'model': self.model,
         })
 
 
diff --git a/netbox/templates/dcim/rack_elevation_list.html b/netbox/templates/dcim/rack_elevation_list.html
index ef22bd9b8cd..c9d9a248afb 100644
--- a/netbox/templates/dcim/rack_elevation_list.html
+++ b/netbox/templates/dcim/rack_elevation_list.html
@@ -35,6 +35,10 @@
 {% block content-wrapper %}
   <div class="tab-content">
 
+    {% if filter_form %}
+      {% applied_filters model filter_form request.GET %}
+    {% endif %}
+    
     {# Rack elevations #}
     <div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
       {% if page %}


Code review comments:
diff_hunk: @@ -691,6 +692,7 @@ def get(self, request):
             'sort_choices': ORDERING_CHOICES,
             'rack_face': rack_face,
             'filter_form': forms.RackElevationFilterForm(request.GET),
+            'model': self.model,
path: netbox/dcim/views.py
text: @user1:
```suggestion
            'model': self.queryset.model,
```

diff_hunk: @@ -652,6 +652,7 @@ def get(self, request):
 
         racks = filtersets.RackFilterSet(request.GET, self.queryset).qs
         total_count = racks.count()
+        self.model = self.queryset.model
path: netbox/dcim/views.py
text: @user1:
We can avoid setting the model on the instance and just pass it directly as context for the template.
```suggestion
```