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

Dynamic Group filter criteria support for relationships #3220

Closed
lampwins opened this issue Feb 2, 2023 · 2 comments · Fixed by #3353
Closed

Dynamic Group filter criteria support for relationships #3220

lampwins opened this issue Feb 2, 2023 · 2 comments · Fixed by #3353
Assignees
Labels
type: feature Introduction of new or enhanced functionality to the application

Comments

@lampwins
Copy link
Member

lampwins commented Feb 2, 2023

As ...

Austin - Network Automation Engineer

I want ...

To be able to specify relationship associations as a part of dynamic group filter criteria

So that ...

I can use the relationships to refine the filter

I know this is done when...

I can see and use relationships defined for the specified content type when modifying the filter criteria

Optional - Feature groups this request pertains to.

  • Automation
  • Organization

Database Changes

No response

External Dependencies

No response

@lampwins lampwins added the type: feature Introduction of new or enhanced functionality to the application label Feb 2, 2023
@glennmatthews
Copy link
Contributor

We'll need to be careful to quantify how this feature could potentially degrade performance of dynamic groups even further.

@jathanism jathanism self-assigned this Feb 21, 2023
@jathanism
Copy link
Contributor

jathanism commented Feb 21, 2023

It's simple enough to remove the gate for fields prefixed with cr_ from DynamicGroup.exclude_filter_fields:

diff --git a/nautobot/extras/models/groups.py b/nautobot/extras/models/groups.py
index 9b88f7bfd..6cb2825b2 100644
--- a/nautobot/extras/models/groups.py
+++ b/nautobot/extras/models/groups.py
@@ -75,7 +75,7 @@ class DynamicGroup(OrganizationalModel):
     # to dynamically change the widget if we decide we do want to support this field.
     #
     # Type: tuple
-    exclude_filter_fields = ("q", "cf_", "cr_", "cpf_", "comments")  # Must be a tuple
+    exclude_filter_fields = ("q", "cf_", "cpf_", "comments")  # Must be a tuple

     class Meta:
         ordering = ["content_type", "name"]
(END)

This allows the filter and the generated filter form to store and emit this filter value. And this will work for custom fields as well. The problem is that the current machinery for rendering forms is explicitly skipping custom fields and relationships is not uniform. So while it works because RelationshipModelFilterFormMixin is adding self.relationships to the filter form, the same is not true for CustomFieldModelFilterFormMixin.

In any case, this will be better to solve by integrating the dynamic filter field from input into the Dynamic Group edit view to align the code paths and leave this issue behind. See: #2782

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new or enhanced functionality to the application
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants