Refactor taxa list endpoints to follow the project-user membership API #1104
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.
Summary
Refactors taxa list endpoints to use a through model (
TaxaListTaxon) instead of custom POST actions, following the same pattern as the project membership API for consistency and better RESTful design.Changes
Backend
Created TaxaListTaxon through model (
ami/main/models.py:3606)TaxaListandTaxon(taxa_list, taxon)Database migration (
ami/main/migrations/0081_add_taxalist_taxon_through_model.py)TaxaList.taxato use through parameterCreated serializers (
ami/main/api/serializers.py:672)TaxaListTaxonSerializer- Create/update with validationTaxaListTaxonListSerializer- Simplified for list viewsCreated TaxaListTaxonViewSet (
ami/main/api/views.py:1633)delete_by_taxonaction for convenienceUpdated router (
config/api_router.py:40)/taxa/lists/{taxalist_id}/taxa/Removed deprecated actions
add_taxon()action from TaxaListViewSetremove_taxon()action from TaxaListViewSetFrontend
Updated useAddTaxaListTaxon hook
POST /taxa/lists/{id}/add_taxon/toPOST /taxa/lists/{id}/taxa/Updated useRemoveTaxaListTaxon hook
POST /taxa/lists/{id}/remove_taxon/toDELETE /taxa/lists/{id}/taxa/by-taxon/{taxon_id}/Tests
ami/main/tests/test_taxa_list_taxa_api.py)API Changes
New Endpoints
GET /taxa/lists/{id}/taxa/- List taxa in a taxa listPOST /taxa/lists/{id}/taxa/- Add taxon (201 Created, 400 if duplicate)GET /taxa/lists/{id}/taxa/{membership_id}/- Retrieve membership detailsDELETE /taxa/lists/{id}/taxa/{membership_id}/- Remove by membership ID (204 No Content)DELETE /taxa/lists/{id}/taxa/by-taxon/{taxon_id}/- Remove by taxon ID (204 No Content, 404 if not found)Removed Endpoints
(deprecated)POST /taxa/lists/{id}/add_taxon/(deprecated)POST /taxa/lists/{id}/remove_taxon/Benefits
Testing
Checklist
🤖 Generated with Claude Code