[ARVADOS] updated: ccc1201e103e168b04801b135b662577d7ea475b

Git user git at public.curoverse.com
Fri Dec 16 10:58:12 EST 2016


Summary of changes:
 .../controllers/container_requests_controller.rb   | 28 ++++++++++++++++++++++
 .../controllers/pipeline_instances_controller.rb   |  2 +-
 .../application/_extra_tab_line_buttons.html.erb   |  0
 .../views/application/_title_and_buttons.html.erb  |  3 +++
 .../_extra_tab_line_buttons.html.erb               | 10 ++++++++
 apps/workbench/config/routes.rb                    |  1 +
 .../container_requests_controller_test.rb          | 27 +++++++++++++++++++++
 7 files changed, 70 insertions(+), 1 deletion(-)
 copy tools/crunchstat-summary/tests/__init__.py => apps/workbench/app/views/application/_extra_tab_line_buttons.html.erb (100%)
 create mode 100644 apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb

       via  ccc1201e103e168b04801b135b662577d7ea475b (commit)
       via  190e6d0b21800dcaec1c5d0b2346d2c2bf43eeea (commit)
      from  ba57b6537679889b42693ecd839a94d59c716aaf (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 ccc1201e103e168b04801b135b662577d7ea475b
Merge: ba57b65 190e6d0
Author: radhika <radhika at curoverse.com>
Date:   Tue Dec 13 12:12:58 2016 -0500

    closes #10677
    Merge branch '10677-container-request-rerun'


commit 190e6d0b21800dcaec1c5d0b2346d2c2bf43eeea
Author: radhika <radhika at curoverse.com>
Date:   Tue Dec 13 10:44:16 2016 -0500

    10677: Add a Re-run button to container_request#show page.

diff --git a/apps/workbench/app/controllers/container_requests_controller.rb b/apps/workbench/app/controllers/container_requests_controller.rb
index b67d100..b286a94 100644
--- a/apps/workbench/app/controllers/container_requests_controller.rb
+++ b/apps/workbench/app/controllers/container_requests_controller.rb
@@ -59,4 +59,32 @@ class ContainerRequestsController < ApplicationController
     end
   end
 
+  def copy
+    src = @object
+
+    @object = ContainerRequest.new
+
+    @object.command = src.command
+    @object.container_image = src.container_image
+    @object.cwd = src.cwd
+    @object.description = src.description
+    @object.environment = src.environment
+    @object.mounts = src.mounts
+    @object.name = src.name
+    @object.output_path = src.output_path
+    @object.priority = 1
+    @object.properties[:template_uuid] = src.properties[:template_uuid]
+    @object.runtime_constraints = src.runtime_constraints
+    @object.scheduling_parameters = src.scheduling_parameters
+    @object.state = 'Uncommitted'
+    @object.use_existing = false
+
+    # set owner_uuid to that of source, provided it is a project and writable by current user
+    current_project = Group.find(src.owner_uuid) rescue nil
+    if (current_project && current_project.writable_by.andand.include?(current_user.uuid))
+      @object.owner_uuid = src.owner_uuid
+    end
+
+    super
+  end
 end
diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb
index c5fbda0..83fe0dd 100644
--- a/apps/workbench/app/controllers/pipeline_instances_controller.rb
+++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb
@@ -53,7 +53,7 @@ class PipelineInstancesController < ApplicationController
     end
     @object.state = 'New'
 
-    # set owner_uuid to that of source, provided it is a project and wriable by current user
+    # set owner_uuid to that of source, provided it is a project and writable by current user
     current_project = Group.find(source.owner_uuid) rescue nil
     if (current_project && current_project.writable_by.andand.include?(current_user.uuid))
       @object.owner_uuid = source.owner_uuid
diff --git a/apps/workbench/app/views/application/_extra_tab_line_buttons.html.erb b/apps/workbench/app/views/application/_extra_tab_line_buttons.html.erb
new file mode 100644
index 0000000..e69de29
diff --git a/apps/workbench/app/views/application/_title_and_buttons.html.erb b/apps/workbench/app/views/application/_title_and_buttons.html.erb
index 398f248..46a949a 100644
--- a/apps/workbench/app/views/application/_title_and_buttons.html.erb
+++ b/apps/workbench/app/views/application/_title_and_buttons.html.erb
@@ -13,6 +13,9 @@
 
 <% if @object.class.goes_in_projects? && @object.uuid != current_user.andand.uuid # Not the "Home" project %>
   <% content_for :tab_line_buttons do %>
+    <% if current_user.andand.is_active %>
+      <%= render partial: 'extra_tab_line_buttons' %>
+    <% end %>
     <% if current_user.andand.is_active && @object.class.copies_to_projects? %>
       <%= link_to(
           choose_projects_path(
diff --git a/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb b/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb
new file mode 100644
index 0000000..662309f
--- /dev/null
+++ b/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb
@@ -0,0 +1,10 @@
+<% if @object.state == 'Final' %>
+  <%= link_to(copy_container_request_path('id' => @object.uuid),
+      class: 'btn btn-primary',
+      title: 'Re-run',
+      data: {toggle: :tooltip, placement: :top}, title: 'This will make a copy and take you there. You can then make any needed changes and run it',
+      method: :post,
+      ) do %>
+    <i class="fa fa-fw fa-play"></i> Re-run
+  <% end %>
+<% end %>
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 7c2312c..21cb7c4 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -26,6 +26,7 @@ ArvadosWorkbench::Application.routes.draw do
   resources :containers
   resources :container_requests do
     post 'cancel', :on => :member
+    post 'copy', on: :member
   end
   get '/virtual_machines/:id/webshell/:login' => 'virtual_machines#webshell', :as => :webshell_virtual_machine
   resources :authorized_keys
diff --git a/apps/workbench/test/controllers/container_requests_controller_test.rb b/apps/workbench/test/controllers/container_requests_controller_test.rb
index 8dbbbd0..70e042c 100644
--- a/apps/workbench/test/controllers/container_requests_controller_test.rb
+++ b/apps/workbench/test/controllers/container_requests_controller_test.rb
@@ -29,4 +29,31 @@ class ContainerRequestsControllerTest < ActionController::TestCase
     assert_includes @response.body, '<div id="event_log_div"'
     assert_select 'Download the log', false
   end
+
+  test "completed container request offers re-run option" do
+    use_token 'active'
+
+    uuid = api_fixture('container_requests')['completed']['uuid']
+
+    get :show, {id: uuid}, session_for(:active)
+    assert_response :success
+
+   assert_includes @response.body, "href=\"/container_requests/#{uuid}/copy\""
+  end
+
+  test "container request copy" do
+    completed_cr = api_fixture('container_requests')['completed']
+    post(:copy,
+         {
+           id: completed_cr['uuid']
+         },
+         session_for(:active))
+    assert_response 302
+    copied_cr = assigns(:object)
+    assert_not_nil copied_cr
+    assert_equal 'Uncommitted', copied_cr[:state]
+    assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
+    assert_equal completed_cr['cmd'], copied_cr['cmd']
+    assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
+  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list