[ARVADOS] updated: ebf38316d1d47715b629ea35c66c93f28e66d76c

git at public.curoverse.com git at public.curoverse.com
Thu Oct 16 16:19:08 EDT 2014


Summary of changes:
 apps/workbench/app/models/arvados_base.rb                      |  4 +++-
 services/api/app/models/arvados_model.rb                       |  3 ++-
 services/api/app/models/user.rb                                |  1 +
 .../api/test/functional/arvados/v1/users_controller_test.rb    | 10 ++++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

       via  ebf38316d1d47715b629ea35c66c93f28e66d76c (commit)
       via  9270b0a9b8beae722d3a9d2c536c0e9599d89c2d (commit)
       via  a64a976d68a0bb069ec4a185ed20a503d780246c (commit)
      from  00f628861c69a1faef520b651b2f733d3981672d (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 ebf38316d1d47715b629ea35c66c93f28e66d76c
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 16 16:17:51 2014 -0400

    4189: Add writable_by to User API response, so writable_by is available for every owner_uuid.

diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 422ce01..13ccd70 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -110,7 +110,8 @@ class ArvadosModel < ActiveRecord::Base
     unless (owner_uuid == current_user.uuid or
             current_user.is_admin or
             (current_user.groups_i_can(:manage) & [uuid, owner_uuid]).any?)
-      if (current_user.groups_i_can(:write) & [uuid, owner_uuid]).any?
+      if ((current_user.groups_i_can(:write) + [current_user.uuid]) &
+          [uuid, owner_uuid]).any?
         return [owner_uuid, current_user.uuid]
       else
         return [owner_uuid]
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 6e7facd..ecd50cc 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -29,6 +29,7 @@ class User < ArvadosModel
     t.add :is_admin
     t.add :is_invited
     t.add :prefs
+    t.add :writable_by
   end
 
   ALL_PERMISSIONS = {read: true, write: true, manage: true}
diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb
index 9c4d18b..2d26370 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -779,6 +779,16 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_equal false, found_email, 'Expected no email after updating profile'
   end
 
+  test "user API response includes writable_by" do
+    authorize_with :active
+    get :current
+    assert_response :success
+    assert_includes(json_response["writable_by"], users(:active).uuid,
+                    "user's writable_by should include self")
+    assert_includes(json_response["writable_by"], users(:active).owner_uuid,
+                    "user's writable_by should include its owner_uuid")
+  end
+
 
   NON_ADMIN_USER_DATA = ["uuid", "kind", "is_active", "email", "first_name",
                          "last_name"].sort

commit 9270b0a9b8beae722d3a9d2c536c0e9599d89c2d
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 16 16:11:13 2014 -0400

    4189: Admit in writable_by that an object is writable when its owner_uuid is writable.

diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 823fd55..422ce01 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -110,7 +110,7 @@ class ArvadosModel < ActiveRecord::Base
     unless (owner_uuid == current_user.uuid or
             current_user.is_admin or
             (current_user.groups_i_can(:manage) & [uuid, owner_uuid]).any?)
-      if current_user.groups_i_can(:write).index(uuid)
+      if (current_user.groups_i_can(:write) & [uuid, owner_uuid]).any?
         return [owner_uuid, current_user.uuid]
       else
         return [owner_uuid]

commit a64a976d68a0bb069ec4a185ed20a503d780246c
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 16 16:09:16 2014 -0400

    4189: Look up owner's writable_by when API did not provide writable_by for the object in question.

diff --git a/apps/workbench/app/models/arvados_base.rb b/apps/workbench/app/models/arvados_base.rb
index cbc65f3..f5be0e1 100644
--- a/apps/workbench/app/models/arvados_base.rb
+++ b/apps/workbench/app/models/arvados_base.rb
@@ -329,7 +329,9 @@ class ArvadosBase < ActiveRecord::Base
      (current_user.is_admin or
       current_user.uuid == self.owner_uuid or
       new_record? or
-      (writable_by.include? current_user.uuid rescue false))) or false
+      (respond_to?(:writable_by) ?
+       writable_by.include?(current_user.uuid) :
+       (ArvadosBase.find(owner_uuid).writable_by.include? current_user.uuid rescue false)))) or false
   end
 
   # Array of strings that are the names of attributes that can be edited

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list