diff --git a/changes/117.added b/changes/117.added new file mode 100644 index 0000000..f465a72 --- /dev/null +++ b/changes/117.added @@ -0,0 +1 @@ +Added filter extension to be able to filter racks that are assigned/unassigned to a floor plan tile. \ No newline at end of file diff --git a/nautobot_floor_plan/filter_extensions.py b/nautobot_floor_plan/filter_extensions.py index f683db7..8b1ab2c 100644 --- a/nautobot_floor_plan/filter_extensions.py +++ b/nautobot_floor_plan/filter_extensions.py @@ -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 @@ -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", + ), } diff --git a/nautobot_floor_plan/forms.py b/nautobot_floor_plan/forms.py index 127f30e..12f5a63 100644 --- a/nautobot_floor_plan/forms.py +++ b/nautobot_floor_plan/forms.py @@ -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(),