-
Notifications
You must be signed in to change notification settings - Fork 31
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
HydroShare Update Resource #2580
Conversation
When POSTing new files to /export/hydroshare?project=XX for a project that has already been exported, we now update the files for it in HydroShare and send back the updated Hydro- ShareResource entity with an updated exported_at date.
This will likely be superseded by styling and UI changes in #2574, but serves the purpose of exercising the new backend code and demonstrating how updates are expected to execute.
00b26fd
to
06234d1
Compare
Taking a look now! |
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.
Tested and working!
src/mmw/apps/export/views.py
Outdated
# POST existing resource updates it | ||
if hsresource and request.method == 'POST': | ||
# Update files | ||
files = params.get('files', []) |
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.
Could this be moved out to a helper function and called from L144? If we're creating a file for the first time it will pass on trying to delete it, so it should have the same behavior in both cases.
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.
Effectively same behavior, but an extra API call per file. Still, the similarities are too much to ignore. I'll abstract it into a helper function.
Just posted a refactor in a927bd0 that creates a helper class for HydroShare and abstracts the |
Nice, going to test this out one more time. |
+1, still working. |
Thanks for taking a look! Merging now. |
Overview
Adds the ability to re-export to HydroShare. We cannot edit the title, abstract, or keyword list using hs_restclient after the resource has been first created, so this deletes any existing files from the new payload and re-exports them. If the resource has any files outside of the list specified in the request body, they will be unaffected.
Connects #2573
Demo
Notes
Regarding versioning, I tested adding it:
which created and returned a new resource, which in the UI linked to the old one:
and the old resource was updated with a link to the new one:
This old resource could then no longer be edited from the HydroShare UI. I'm not sure if this behavior is desirable, so I'm not adding it at this point (otherwise we'd get a new resource every time any change is made to the project in MMW), but we can revisit it in the future.
Testing Instructions