[ARVADOS] updated: 8e6ea9f0058ba3809d926ac9e704390d95a58514
git at public.curoverse.com
git at public.curoverse.com
Fri Jun 13 13:43:40 EDT 2014
Summary of changes:
.../app/controllers/application_controller.rb | 44 ++++++++++++++++++++++
.../app/controllers/collections_controller.rb | 2 +
2 files changed, 46 insertions(+)
via 8e6ea9f0058ba3809d926ac9e704390d95a58514 (commit)
from d458a1106d390a87b7f7347cbd4fe801e8014f51 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 8e6ea9f0058ba3809d926ac9e704390d95a58514
Author: radhika <radhika at curoverse.com>
Date: Fri Jun 13 13:42:26 2014 -0400
2659: when a collection is un/shared, un/share it with anonymous user group as well.
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index d8f3f3e..a3545d0 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -683,4 +683,48 @@ class ApplicationController < ActionController::Base
@objects_for
end
+ @@anonymous_group = nil
+ def self.anonymous_group
+ if !@@anonymous_group
+ @@anonymous_group = Group.where(name: 'Anonymous group').first
+ end
+ @@anonymous_group
+ end
+
+ # helper method to create sharing link for anonymous user group
+ helper_method :share_with_anonymous_user
+ def share_with_anonymous_group uuid
+ anon_group = ApplicationController.anonymous_group
+ return if !anon_group
+
+ links = Link.where(link_class: 'permission',
+ name: 'can_read',
+ tail_uuid: anon_group[:uuid],
+ head_uuid: uuid)
+
+ # no such link exists; so create one
+ if !links.any?
+ link = Link.create(link_class: 'permission',
+ name: 'can_read',
+ tail_uuid: anon_group[:uuid],
+ head_uuid: uuid)
+ end
+ end
+
+ # helper method to delete sharing link for anonymous user group
+ helper_method :unshare_with_anonymous_user
+ def unshare_with_anonymous_group uuid
+ anon_group = ApplicationController.anonymous_group
+ return if !anon_group
+
+ links = Link.where(link_class: 'permission',
+ name: 'can_read',
+ tail_uuid: anon_group[:uuid],
+ head_uuid: uuid)
+
+ links.each do |link|
+ link.destroy
+ end
+ end
+
end
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 6a5df87..f0eea06 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -187,6 +187,7 @@ class CollectionsController < ApplicationController
def share
a = ApiClientAuthorization.create(scopes: sharing_scopes)
+ share_with_anonymous_group @object.uuid
@search_sharing = search_scopes
render 'sharing_popup'
end
@@ -197,6 +198,7 @@ class CollectionsController < ApplicationController
s.destroy
end
@search_sharing = search_scopes
+ unshare_with_anonymous_group @object.uuid
render 'sharing_popup'
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list