Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unique rack filter custom extension for quality of life improve… #118

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
),
}
djhoward12 marked this conversation as resolved.
Show resolved Hide resolved


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