Add users transfer_resources to hand resources to another user - #141
Open
christianbraun wants to merge 1 commit into
Open
Add users transfer_resources to hand resources to another user#141christianbraun wants to merge 1 commit into
christianbraun wants to merge 1 commit into
Conversation
geonodectl users transfer_resources 3 --new_owner 7
geonodectl users transfer_resources 3 --new_owner 7 --resources 11 12
Wraps POST /api/v2/users/{pk}/transfer_resources, which exists in two shapes.
GeoNode 5 takes newOwner, currentOwner and an optional list of resource ids;
GeoNode 4.4 takes a single `owner` and always moves every resource of the user.
The modern payload goes out first and the legacy one is only tried after
GeoNode answers that it did not understand it. A subset is never retried that
way, since the 4.4 endpoint would move everything rather than the resources
that were asked for.
`resources` is always sent, empty for a whole-account transfer: GeoNode 5
raises a TypeError on a JSON body that leaves the key out entirely.
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.
Adds the one thing that was missing to move a resource to a different owner from the command line:
POST /api/v2/users/{pk}/transfer_resourcesexists in two shapes. GeoNode 5 takesnewOwner,currentOwnerand an optional list of resource ids; GeoNode 4.4 takes a singleownerand always moves every resource the user owns. The modern payload goes out first, and the legacy one is only tried after GeoNode answers that it did not understand it. A subset is never retried that way - the 4.4 endpoint would move everything rather than the resources that were asked for, so that case raises instead.resourcesis always sent, empty for a whole-account transfer. GeoNode 5 raises aTypeErroron a JSON body that leaves the key out entirely (GeoNode/geonode#14473), and an empty list walks around it.Four unit tests in
tests/test_users.py, mockinghttp_postin the same style as the existing handler tests.unittest discoveris green (48 tests),blackandflake8clean,mypy -p src.geonoderest --check-untyped-defs --disable-error-code=import-untypedreports only the pre-existingraise NotImplementedingeonodectl.py.Not tested against a live GeoNode yet - review welcome on whether the version fallback is the shape you want, or whether you would rather gate it on a configured API version.