Touch up #3559 based on post-merge discussions.

This commit is contained in:
John Chilton
2017-04-03 12:35:57 -04:00
parent 5169fbe917
commit 1e70211fa4
3 changed files with 11 additions and 17 deletions
@@ -258,8 +258,9 @@ class FolderContentsController( BaseAPIController, UsesLibraryMixin, UsesLibrary
:type extended_metadata: dict
:type payload: dict
:returns: a list of dictionaries containing the id, name, and 'show' url of the new item
:rtype: list
:returns: a dictionary describing the new item if ``from_hda_id`` is supplied or a list of
such dictionaries describing the new items if ``from_hdca_id`` is supplied.
:rtype: object
:raises: ObjectAttributeInvalidException,
InsufficientPermissionsException, ItemAccessibilityException,
@@ -271,14 +272,13 @@ class FolderContentsController( BaseAPIController, UsesLibraryMixin, UsesLibrary
ldda_message = payload.pop( 'ldda_message', '' )
if ldda_message:
ldda_message = util.sanitize_html.sanitize_html( ldda_message, 'utf-8' )
rvals = []
try:
if from_hda_id:
decoded_hda_id = self.decode_id( from_hda_id )
rvals.append(self._copy_hda_to_library_folder( trans, self.hda_manager, decoded_hda_id, encoded_folder_id_16, ldda_message ))
return self._copy_hda_to_library_folder( trans, self.hda_manager, decoded_hda_id, encoded_folder_id_16, ldda_message )
if from_hdca_id:
decoded_hdca_id = self.decode_id( from_hdca_id )
rvals.extend(self._copy_hdca_to_library_folder( trans, self.hda_manager, decoded_hdca_id, encoded_folder_id_16, ldda_message ))
return self._copy_hdca_to_library_folder( trans, self.hda_manager, decoded_hdca_id, encoded_folder_id_16, ldda_message )
except Exception as exc:
# TODO handle exceptions better within the mixins
if 'not accessible to the current user' in str( exc ) or 'You are not allowed to access this dataset' in str( exc ):
@@ -286,7 +286,6 @@ class FolderContentsController( BaseAPIController, UsesLibraryMixin, UsesLibrary
else:
log.exception( exc )
raise exc
return rvals
def __decode_library_content_id( self, trans, encoded_folder_id ):
"""
@@ -183,9 +183,9 @@ class LibraryContentsController( BaseAPIController, UsesLibraryMixin, UsesLibrar
* description: (optional, only if create_type is 'folder')
description of the folder to create
:rtype: list
:returns: a list of dictionaries containing the id, name,
and 'show' url of the new item
:returns: a dictionary describing the new item unless ``from_hdca_id`` is supplied,
in that case a list of such dictionaries is returned.
:rtype: object
"""
if 'create_type' not in payload:
trans.response.status = 400
@@ -213,15 +213,11 @@ class LibraryContentsController( BaseAPIController, UsesLibraryMixin, UsesLibrar
# are we copying an HDA to the library folder?
# we'll need the id and any message to attach, then branch to that private function
from_hda_id, from_hdca_id, ldda_message = ( payload.pop( 'from_hda_id', None ), payload.pop( 'from_hdca_id', None ), payload.pop( 'ldda_message', '' ) )
log.debug(payload)
if create_type == 'file':
rval = []
if from_hda_id:
rval.append(self._copy_hda_to_library_folder( trans, self.hda_manager, self.decode_id(from_hda_id), real_folder_id, ldda_message ))
return self._copy_hda_to_library_folder( trans, self.hda_manager, self.decode_id(from_hda_id), real_folder_id, ldda_message )
if from_hdca_id:
rval.extend(self._copy_hdca_to_library_folder(trans, self.hda_manager, self.decode_id(from_hdca_id), real_folder_id, ldda_message))
if from_hda_id or from_hdca_id:
return rval
return self._copy_hdca_to_library_folder(trans, self.hda_manager, self.decode_id(from_hdca_id), real_folder_id, ldda_message)
# check for extended metadata, store it and pop it out of the param
# otherwise sanitize_param will have a fit
+1 -2
View File
@@ -111,8 +111,7 @@ class LibrariesApiTestCase( api.ApiTestCase, TestsDatasets ):
payload = {'from_hda_id': hda_id}
create_response = self._post( "folders/%s/contents" % folder_id, payload )
self._assert_status_code_is( create_response, 200 )
library_datasets = create_response.json()
assert len( library_datasets ) == 1
self._assert_has_keys( create_response.json(), "name", "id" )
def test_create_datasets_in_library_from_collection( self ):
library = self.library_populator.new_private_library( "ForCreateDatasetsFromCollection" )