Skip to content
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

Merged
merged 3 commits into from
Jan 2, 2018
Merged

Conversation

rajadain
Copy link
Member

@rajadain rajadain commented Dec 28, 2017

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

2017-12-29 12 43 08

Notes

Regarding versioning, I tested adding it:

hs.resource(hsresource.resource).version()

which created and returned a new resource, which in the UI linked to the old one:

screen shot 2017-12-29 at 10 54 15 am

and the old resource was updated with a link to the new one:

screen shot 2017-12-29 at 10 54 26 am

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

  • Check out this branch, and make sure you are setup for HydroShare
  • Create a new project, and export it to HydroShare
  • Log in to HydroShare and delete some of the CSV files
  • In MMW, re-export to HydroShare. Ensure that all the CSV files have been recreated.

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.
@rajadain rajadain force-pushed the tt/hydroshare-export-update-resource branch from 00b26fd to 06234d1 Compare December 29, 2017 16:18
@rajadain rajadain changed the title WIP HydroShare Update Resource HydroShare Update Resource Dec 29, 2017
@arottersman
Copy link

Taking a look now!

Copy link

@arottersman arottersman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and working!

# POST existing resource updates it
if hsresource and request.method == 'POST':
# Update files
files = params.get('files', [])

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.

Copy link
Member Author

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.

@arottersman arottersman assigned rajadain and unassigned arottersman Jan 2, 2018
Create a helper class HydroShareClient to group utility methods
under. Create an add_files method that encapsulates the posting
of files to HydroShare, and takes an optional overwrite flag to
signify deletion first.
@rajadain
Copy link
Member Author

rajadain commented Jan 2, 2018

Just posted a refactor in a927bd0 that creates a helper class for HydroShare and abstracts the add_files method there.

@arottersman
Copy link

Nice, going to test this out one more time.

@arottersman
Copy link

+1, still working.

@rajadain
Copy link
Member Author

rajadain commented Jan 2, 2018

Thanks for taking a look! Merging now.

@rajadain rajadain merged commit 9fa1814 into develop Jan 2, 2018
@rajadain rajadain deleted the tt/hydroshare-export-update-resource branch January 2, 2018 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants