-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GraphQL query form field to the "Generate Intended Config" view (#…
…841)
- Loading branch information
1 parent
49caca7
commit 1e1fda6
Showing
9 changed files
with
140 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added GraphQL query form field to the "Generate Intended Config" view. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""FilterSet and FilterForm extensions for the Golden Config app.""" | ||
|
||
from django.db.models import Q | ||
from nautobot.apps.filters import FilterExtension, MultiValueCharFilter | ||
|
||
|
||
def filter_graphql_query_variables(queryset, name, value): # pylint: disable=unused-argument | ||
"""Filter the queryset based on the presence of variables.""" | ||
query = Q() | ||
for variable_name in value: | ||
query |= Q(**{f"variables__{variable_name}__isnull": True}) | ||
return queryset.exclude(query) | ||
|
||
|
||
class GraphQLQueryFilterExtension(FilterExtension): | ||
"""Filter extensions for the extras.GraphQLQuery model.""" | ||
|
||
model = "extras.graphqlquery" | ||
|
||
filterset_fields = { | ||
"nautobot_golden_config_graphql_query_variables": MultiValueCharFilter( | ||
field_name="variables", | ||
lookup_expr="exact", | ||
method=filter_graphql_query_variables, | ||
label="Variable key(s) exist", | ||
), | ||
} | ||
|
||
|
||
filter_extensions = [GraphQLQueryFilterExtension] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters