[ARVADOS] created: 108467e2b85c9f3c44b483bc79f68acf6ae3b963
Git user
git at public.curoverse.com
Wed Feb 8 11:20:37 EST 2017
at 108467e2b85c9f3c44b483bc79f68acf6ae3b963 (commit)
commit 108467e2b85c9f3c44b483bc79f68acf6ae3b963
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Wed Feb 8 13:18:36 2017 -0300
3900: When deleting items inside a project, use the delete API. In the special case of trashing collections, first remove them from its parent project.
diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index 273f9d0..9a556d5 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -149,17 +149,11 @@ class ProjectsController < ApplicationController
link.destroy
end
- # If this object has the 'trash_at' attribute, then simply mark it
- # as trash.
- if item.attributes.include?("trash_at")
- item.update_attributes trash_at: Time.now
- @removed_uuids << item.uuid
- elsif item.owner_uuid == @object.uuid
- # Object is owned by this project. Remove it from the project by
- # changing owner to the current user.
+ if item.class == Collection && item.owner_uuid == @object.uuid
+ # Collection is owned by this project. Remove it from the project by
+ # changing owner to the current user before asking for deletion.
begin
item.update_attributes owner_uuid: current_user.uuid
- @removed_uuids << item.uuid
rescue ArvadosApiClient::ApiErrorResponseException => e
if e.message.include? '_owner_uuid_'
rename_to = item.name + ' removed from ' +
@@ -169,12 +163,13 @@ class ProjectsController < ApplicationController
updates[:name] = rename_to
updates[:owner_uuid] = current_user.uuid
item.update_attributes updates
- @removed_uuids << item.uuid
else
raise
end
end
end
+ @removed_uuids << item.uuid
+ item.destroy
end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list