Use Filterset Factory in Project and Sample Views#1868
Open
Use Filterset Factory in Project and Sample Views#1868
Conversation
…project and sample views to auto-generate FilterSet
…ld project__scpca_id)
This was referenced Mar 12, 2026
davidsmejia
reviewed
Mar 13, 2026
api/scpca_portal/views/sample.py
Outdated
| Sample, | ||
| include_fields=[ | ||
| "scpca_id", | ||
| "project__scpca_id", |
Contributor
There was a problem hiding this comment.
Suggested change
| "project__scpca_id", |
| # timestamps | ||
| "created_at", | ||
| "updated_at", | ||
| ], |
Contributor
There was a problem hiding this comment.
Suggested change
| ], | |
| ], | |
| extra_filters = { | |
| "project__scpca_id": ["exact"], | |
| }, |
Contributor
|
Can you add a test to ensure that this case is handled |
davidsmejia
reviewed
Mar 13, 2026
api/scpca_portal/filter.py
Outdated
Comment on lines
+73
to
+77
| # Add other custom lookup fields included in include_fields | ||
| if include_fields: | ||
| for field in include_fields: | ||
| if field not in meta_fields and field not in declared_filters: | ||
| meta_fields[field] = ["exact", "icontains"] |
Contributor
There was a problem hiding this comment.
Suggested change
| # Add other custom lookup fields included in include_fields | |
| if include_fields: | |
| for field in include_fields: | |
| if field not in meta_fields and field not in declared_filters: | |
| meta_fields[field] = ["exact", "icontains"] |
…s parameter for additional fields that should be filterable via the public API, and adjust views' arguments accordingly
Member
Author
|
I've:
This PR is ready for another look. Thank you, David! |
…ger checked as it uses the same TextField as 'scpca_id')
4 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Number
Related Issue #1849
Purpose/Implementation Notes
Changes include:
filtermodule to the project rootfiltermodule to auto-generate the filtersets with default lookup expressions forprojectandsampleendpointsTypes of changes
What types of changes does your code introduce?
Functional tests
localhoste.g. )
http://localhost:8000/v1/projects?diagnoses=Glioblastoma,EpendymomaChecklist
Screenshots
N/A