added collection resource handling to fix the test failure
@@ -592,6 +592,11 @@ def copy_resource(ori_res, new_res):
if hs_identifier:
new_res.metadata.create_element('source', derived_from=hs_identifier.url)
+ if ori_res.resource_type.lower() == "collectionresource":
+ # clone contained_res list of original collection and add to new collection
+ # note that new collection will not contain "deleted resources"
+ new_res.resources = ori_res.resources.all()
+
# create bag for the new resource
hs_bagit.create_bag(new_res, ori_res.resource_federation_path)
@@ -636,6 +641,11 @@ def create_new_version_resource(ori_res, new_res, user):
hs_identifier = ori_res.metadata.identifiers.all().filter(name="hydroShareIdentifier")[0]
new_res.metadata.create_element('relation', type='isVersionOf', value=hs_identifier.url)
+ if ori_res.resource_type.lower() == "collectionresource":
+ # clone contained_res list of original collection and add to new collection
+ # note that new version collection will not contain "deleted resources"
+ new_res.resources = ori_res.resources.all()
+
# create bag for the new resource
hs_bagit.create_bag(new_res, ori_res.resource_federation_path)
