From: radhika Date: Tue, 14 Jun 2016 22:11:29 +0000 (-0400) Subject: 9372: name and description can be edited on containers and container_requests despite... X-Git-Tag: 1.1.0~877^2~6 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/4a6b74c22201ceac36797b7722d52407eec63536 9372: name and description can be edited on containers and container_requests despite the state. --- diff --git a/apps/workbench/app/models/container.rb b/apps/workbench/app/models/container.rb index b52313280a..0a7c288718 100644 --- a/apps/workbench/app/models/container.rb +++ b/apps/workbench/app/models/container.rb @@ -1,4 +1,8 @@ class Container < ArvadosBase + def self.creatable? + false + end + def work_unit(label=nil) ContainerWorkUnit.new(self, label) end diff --git a/apps/workbench/app/models/container_request.rb b/apps/workbench/app/models/container_request.rb index 765300b192..62d8bff042 100644 --- a/apps/workbench/app/models/container_request.rb +++ b/apps/workbench/app/models/container_request.rb @@ -1,4 +1,12 @@ class ContainerRequest < ArvadosBase + def self.creatable? + false + end + + def textile_attributes + [ 'description' ] + end + def work_unit(label=nil) ContainerWorkUnit.new(self, label) end diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb index 2fe1ff0669..d90299531f 100644 --- a/apps/workbench/app/models/container_work_unit.rb +++ b/apps/workbench/app/models/container_work_unit.rb @@ -44,6 +44,12 @@ class ContainerWorkUnit < ProxyWorkUnit "container" end + def uri + uuid = get(:uuid) + "/#{@proxied.class.table_name}/#{uuid}" rescue nil + end + + def can_cancel? @proxied.is_a?(ContainerRequest) && state_label.in?(["Queued", "Locked", "Running"]) && priority > 0 end diff --git a/apps/workbench/app/models/job_work_unit.rb b/apps/workbench/app/models/job_work_unit.rb index 42a39fcdfd..a3f13f388c 100644 --- a/apps/workbench/app/models/job_work_unit.rb +++ b/apps/workbench/app/models/job_work_unit.rb @@ -81,6 +81,11 @@ class JobWorkUnit < ProxyWorkUnit state_label.in? ["Queued", "Running"] end + def uri + uuid = get(:uuid) + "/jobs/#{uuid}" + end + def title "job" end diff --git a/apps/workbench/app/models/pipeline_instance_work_unit.rb b/apps/workbench/app/models/pipeline_instance_work_unit.rb index 7c623935d4..889fa1a7f3 100644 --- a/apps/workbench/app/models/pipeline_instance_work_unit.rb +++ b/apps/workbench/app/models/pipeline_instance_work_unit.rb @@ -43,6 +43,11 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit items end + def uri + uuid = get(:uuid) + "/pipeline_instances/#{uuid}" + end + def title "pipeline" end diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb index 91673371fe..f672c8c64c 100644 --- a/apps/workbench/app/models/proxy_work_unit.rb +++ b/apps/workbench/app/models/proxy_work_unit.rb @@ -322,11 +322,6 @@ class ProxyWorkUnit < WorkUnit resp end - def uri - uuid = get(:uuid) - "/#{@proxied.class.table_name}/#{uuid}" - end - protected def get key, obj=@proxied diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb index 02dc06cc0d..8e81c7c0d8 100644 --- a/apps/workbench/test/integration/application_layout_test.rb +++ b/apps/workbench/test/integration/application_layout_test.rb @@ -303,4 +303,27 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest end end end + + [ + ['jobs', 'running_job_with_components'], + ['pipeline_instances', 'has_component_with_completed_jobs'], + ['container_requests', 'running'], + ['container_requests', 'completed'], + ].each do |type, fixture| + test "edit description for #{type}/#{fixture}" do + obj = api_fixture(type)[fixture] + visit page_with_token "active", "/#{type}/#{obj['uuid']}" + + within('.arv-description-as-subtitle') do + find('.fa-pencil').click + find('.editable-input textarea').set('*Textile description for object*') + find('.editable-submit').click + end + wait_for_ajax + + # verify description + assert page.has_no_text? '*Textile description for object*' + assert page.has_text? 'Textile description for object' + end + end end diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb index 83ca3346de..496a6b141d 100644 --- a/services/api/app/models/container_request.rb +++ b/services/api/app/models/container_request.rb @@ -129,8 +129,8 @@ class ContainerRequest < ArvadosModel errors.add :priority, "cannot be nil" end - # Can update priority, container count. - permitted.push :priority, :container_count_max, :container_uuid + # Can update priority, container count, name and description + permitted.push :priority, :container_count_max, :container_uuid, :name, :description if self.state_changed? # Allow create-and-commit in a single operation. @@ -141,12 +141,12 @@ class ContainerRequest < ArvadosModel end when Final - if not current_user.andand.is_admin + if not current_user.andand.is_admin and not (self.name_changed? || self.description_changed?) errors.add :state, "of container request can only be set to Final by system." end - if self.state_changed? - permitted.push :state + if self.state_changed? || self.name_changed? || self.description_changed? + permitted.push :state, :name, :description else errors.add :state, "does not allow updates" end diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb index 2c7eb76b2c..df89b93bf4 100644 --- a/services/api/test/unit/container_request_test.rb +++ b/services/api/test/unit/container_request_test.rb @@ -369,7 +369,7 @@ class ContainerRequestTest < ActiveSupport::TestCase end [ - ['active', 'zzzzz-dz642-requestercntnr1'], + ['active', 'zzzzz-dz642-runningcontainr'], ['active_no_prefs', nil], ].each do |token, expected| test "create as #{token} and expect requesting_container_uuid to be #{expected}" do