3661: add centralized method for defining whether an object can be copied to a project
authorPhil Hodgson <bitbucket@philhodgson.net>
Tue, 16 Sep 2014 20:23:08 +0000 (16:23 -0400)
committerPhil Hodgson <bitbucket@philhodgson.net>
Tue, 16 Sep 2014 20:23:08 +0000 (16:23 -0400)
apps/workbench/app/models/arvados_base.rb
apps/workbench/app/models/group.rb
apps/workbench/app/views/application/show.html.erb

index 083db9133b15cd4e746fbfca982ec6be3805c904..7bc043cc9e2ccc7fbc79a130bf7ee2d83940815b 100644 (file)
@@ -318,6 +318,12 @@ class ArvadosBase < ActiveRecord::Base
     false
   end
 
+  # can this class of object be copied into a project?
+  # override to false on indivudal model classes for which this should not be true
+  def self.copies_to_projects?
+    self.goes_in_projects?
+  end
+
   def editable?
     (current_user and current_user.is_active and
      (current_user.is_admin or
index d47819893a84296685ef1fd9a9d9fc81ae8d98ea..3f5da155c4ca9fc5ea13d0836551a92c3c11d435 100644 (file)
@@ -3,6 +3,10 @@ class Group < ArvadosBase
     true
   end
 
+  def self.copies_to_projects?
+    false
+  end
+
   def self.contents params={}
     res = arvados_api_client.api self, "/contents", {
       _method: 'GET'
index 264e019dc0b004e579f1805c97c4bf39f63c3376..ac7433575e4f68d8935fb1ffeeb31d91aebf1c2a 100644 (file)
@@ -8,20 +8,22 @@
 
 <% if @object.class.goes_in_projects? && @object.uuid != current_user.uuid # Not the "Home" project %>
   <% content_for :tab_line_buttons do %>
-    <%= link_to(
-        choose_projects_path(
-         title: 'Copy to project...',
-         action_name: 'Copy',
-         action_href: actions_path,
-         action_method: 'post',
-         action_data: {
-           copy_selections_into_project: true,
-           selection: @name_link.andand.uuid || @object.uuid,
-           selection_param: 'uuid',
-           success: 'redirect-to-created-object'
-         }.to_json),
-        { class: "btn btn-sm btn-primary", remote: true, method: 'get' }) do %>
-      <i class="fa fa-fw fa-copy"></i> Copy to project...
+    <% if @object.class.copies_to_projects? %>
+      <%= link_to(
+          choose_projects_path(
+           title: 'Copy to project...',
+           action_name: 'Copy',
+           action_href: actions_path,
+           action_method: 'post',
+           action_data: {
+             copy_selections_into_project: true,
+             selection: @name_link.andand.uuid || @object.uuid,
+             selection_param: 'uuid',
+             success: 'redirect-to-created-object'
+           }.to_json),
+          { class: "btn btn-sm btn-primary", remote: true, method: 'get' }) do %>
+        <i class="fa fa-fw fa-copy"></i> Copy to project...
+      <% end %>
     <% end %>
     <% if @object.owner_uuid == current_user.uuid or (Group.find(@object.owner_uuid).writable_by.include?(current_user.uuid) rescue nil) %>
       <%= link_to(