-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a839773
commit 117afb2
Showing
4 changed files
with
31 additions
and
7 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,23 @@ | ||
"""Custom filter to extend base API for filterform use case.""" | ||
import django_filters | ||
|
||
from nautobot.apps.filters import FilterExtension | ||
|
||
|
||
def config_plan_null_search(queryset, name, value): | ||
return queryset.filter(config_plan__isnull=False).distinct() | ||
|
||
|
||
class JobResultFilterExtension(FilterExtension): | ||
"""Filter provided to be used in select2 query for only jobs that were used by ConfigPlan.""" | ||
|
||
model = "extras.jobresult" | ||
|
||
filterset_fields = { | ||
"nautobot_golden_config_config_plan_null": django_filters.BooleanFilter( | ||
label="Is FK to ConfigPlan Model", method=config_plan_null_search | ||
) | ||
} | ||
|
||
|
||
filter_extensions = [JobResultFilterExtension] |
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