-
Notifications
You must be signed in to change notification settings - Fork 5
Clean up global vs. project taxa & API responses #853
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
Clean up global vs. project taxa & API responses #853
Conversation
✅ Deploy Preview for antenna-preview canceled.
|
✅ Deploy Preview for antenna-ood canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR standardizes project scoping across Taxon endpoints, adds fallback cover image support, and updates the UI to pass projectId
on searches.
- Require
project_id
for all taxa API endpoints and include global taxa where no project is assigned - Introduce a reusable
TaxonCoverImageField
for cover image URLs in serializers - Allow Taxon and TaxaList records to have no associated projects and update migrations/models accordingly
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
ui/src/components/taxon-search/useTaxonSearch.ts | Add optional projectId parameter to search hook and URL |
ui/src/components/taxon-search/taxon-select.tsx | Propagate new projectId prop through TaxonSelect |
ui/src/components/taxon-search/taxon-search.tsx | Pass projectId into useTaxonSearch |
ui/src/components/filtering/filters/taxon-filter.tsx | Attempt to pass projectId to TaxonSearch (prop not defined) |
ami/main/models.py | Make projects M2M on Taxon and TaxaList blank=True |
ami/main/migrations/0068_allow_taxa_without_project.py | Migration to alter projects fields to allow blank |
ami/main/api/views.py | Enforce require_project , filter global+project taxa, update suggest |
ami/main/api/serializers.py | Add TaxonCoverImageField , replace several SerializerMethodField implementations |
ami/base/views.py | Update get_active_project signature and validation logic |
Comments suppressed due to low confidence (4)
ami/main/api/serializers.py:453
- [nitpick] New logic in
TaxonCoverImageField
(fallback order and URL building) should be covered by unit tests to verify each branch (taxon URL, detection path, and None).
class TaxonCoverImageField(Field):
ui/src/components/filtering/filters/taxon-filter.tsx:52
- The
projectId
prop is used but not destructured from component props. AddprojectId?: string
to the function signature to avoid a ReferenceError.
projectId={projectId}
ami/main/api/serializers.py:473
- The
get_media_url
function is referenced here but not imported in this file. Please add the appropriate import to avoid a NameError.
return get_media_url(obj.best_detection_image_path)
ami/main/api/views.py:1283
- Consider re-adding
.select_related('parent')
on the queryset insuggest
to avoid N+1 queries when serializing parent taxon data.
self.get_queryset()
Summary
Updates the Taxon search endpoint to return cover images in the same way the other Taxon endpoints do. Also updates Taxon endpoints with a number of important changes.
List of Changes
Related Issues
#838
Screenshots
Deployment Notes
Includes one migration that will set all existing Taxa to be global
Checklist