Skip to content

Commit

Permalink
Added unique rack filter custom extension for quality of life improve… (
Browse files Browse the repository at this point in the history
#118)

* Added unique rack filter custom extension for quality of life improvements

* renamed changelog from add to added

* updated filter name per core best practices added back white space.

* Update changes/117.added

Co-authored-by: Joe Wesch <10467633+joewesch@users.noreply.github.com>

* remvoved UniqueRackFilter class and moved filter_set field content under RackFilterExtension

---------

Co-authored-by: DJ Howard <djhoward12@gmail.com.com>
Co-authored-by: Joe Wesch <10467633+joewesch@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 4, 2024
1 parent f7222ae commit cbcf96c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/117.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added filter extension to be able to filter racks that are assigned/unassigned to a floor plan tile.
5 changes: 5 additions & 0 deletions nautobot_floor_plan/filter_extensions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Extensions to Nautobot core models' filtering functionality."""

import django_filters
from nautobot.apps.filters import RelatedMembershipBooleanFilter
from nautobot.extras.plugins import PluginFilterExtension

from nautobot_floor_plan import models
Expand All @@ -17,6 +18,10 @@ class RackFilterExtension(PluginFilterExtension):
field_name="location__floor_plan",
label="Floor plan",
),
"nautobot_floor_plan_has_floor_plan_tile": RelatedMembershipBooleanFilter(
field_name="floor_plan_tile",
label="Floor Plan Tile",
),
}


Expand Down
2 changes: 1 addition & 1 deletion nautobot_floor_plan/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class FloorPlanTileForm(NautobotModelForm):
rack = DynamicModelChoiceField(
queryset=Rack.objects.all(),
required=False,
query_params={"nautobot_floor_plan_floor_plan": "$floor_plan", "rack_group": "$rack_group"},
query_params={"nautobot_floor_plan_floor_plan": "$floor_plan", "nautobot_floor_plan_has_floor_plan_tile": False, "rack_group": "$rack_group"},
)
rack_group = DynamicModelChoiceField(
queryset=RackGroup.objects.all(),
Expand Down

0 comments on commit cbcf96c

Please sign in to comment.