Add admin endpoint to queue collection import on demand (PP-364)#3069
Open
jonathangreen wants to merge 5 commits intomainfrom
Open
Add admin endpoint to queue collection import on demand (PP-364)#3069jonathangreen wants to merge 5 commits intomainfrom
jonathangreen wants to merge 5 commits intomainfrom
Conversation
Add a POST /admin/collection/<id>/import endpoint that allows admins to manually trigger a collection import task. The endpoint validates admin permissions, checks that the collection exists and is not marked for deletion, and queues the import task via Celery. Also adds a `supports_import` flag to protocol details so the admin UI can determine which collections support import, and an IMPORT_NOT_SUPPORTED problem detail for unsupported protocols.
The fragile __mro__ walk in protocol_details and try/except NotImplementedError pattern in the controller are replaced with a SupportsImport ABC mixin and issubclass checks, following the existing HasSelfTests mixin precedent.
2 tasks
OverdriveAPI does not implement SupportsImport, so process_post skips the import step entirely. Remove the now-unnecessary mocks and assertions.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3069 +/- ##
=======================================
Coverage 93.18% 93.18%
=======================================
Files 489 489
Lines 44942 44978 +36
Branches 6191 6197 +6
=======================================
+ Hits 41879 41913 +34
- Misses 1986 1987 +1
- Partials 1077 1078 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Description
POST /admin/collection/<id>/importendpoint allowing system admins to trigger a collection import on demand, with optionalforceparameterSupportsImportABC mixin to explicitly mark circulation APIs that support collection importprotocol_detailstoBaseCirculationAPIexposingsupports_importto the admin UI so it can show/hide the import button per protocolIMPORT_NOT_SUPPORTEDproblem detail for protocols that don't support importMotivation and Context
The admin UI needs to know which collection protocols support import and needs an endpoint to trigger imports. The
SupportsImportmixin follows the existingHasSelfTestspattern in the codebase, making import capability explicit viaissubclasschecks rather than relying ontry/except NotImplementedError.How Has This Been Tested?
process_importcovering: auth requirements, missing service, marked-for-deletion collections, unknown protocols, unsupported protocols, success, and force flag/admin/collection/<id>/importendpoint including invalid collection ID handlingtest_protocol_details_supports_importverifying detection for both supported and unsupported protocolsChecklist