Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions BrainPortal/app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,15 @@ def new #:nodoc:
@task.tool_config = lastest_toolconfig if lastest_toolconfig
end

@tool_config = @task.tool_config # for acces in view
@tool_config = @task.tool_config # for access in view

# Filter list of files as provided by the get request
file_ids = params[:file_ids] || []
access = @task.class.properties[:readonly_input_files] ? :read : :write
if @tool_config.inputs_readonly || @task.class.properties[:readonly_input_files]
access = :read
else
access = :write
end
@files = Userfile.find_accessible_by_user(file_ids, current_user, :access_requested => access) rescue []
if @files.empty?
flash[:error] = "You must select at least one file to which you have write access."
Expand Down
2 changes: 2 additions & 0 deletions BrainPortal/app/controllers/tool_configs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def update #:nodoc:
@tool_config.version_name = other_tc.version_name
@tool_config.group = other_tc.group
@tool_config.ncpus = other_tc.ncpus
@tool_config.inputs_readonly = other_tc.inputs_readonly
@tool_config.container_engine = other_tc.container_engine
@tool_config.containerhub_image_name = other_tc.containerhub_image_name
@tool_config.container_image_userfile_id = other_tc.container_image_userfile_id
Expand Down Expand Up @@ -283,6 +284,7 @@ def tool_config_params #:nodoc:
params.require(:tool_config).permit(
:version_name, :description, :tool_id, :bourreau_id, :env_array, :script_prologue, :script_epilogue,
:group_id, :ncpus, :container_image_userfile_id, :containerhub_image_name, :container_index_location,
:inputs_readonly,
:container_engine, :extra_qsub_args, :singularity_overlays_specs, :container_exec_args,
# The configuration of a tool in a VM managed by a
# ScirCloud Bourreau is defined by the following
Expand Down
8 changes: 8 additions & 0 deletions BrainPortal/app/views/tool_configs/_form_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
</div>
<% end %>

<% t.edit_cell(:inputs_readonly, :header => "Does not modify its inputs files", :show_width => 2) do |f| %>
<%= f.check_box :inputs_readonly %>
<div class="wide_field_explanation">
Check this if the tool is known <strong>not to modify its input files </strong>.
This will allow a user to launch the tool on files that are not marked as group-writable in the file manager.
</div>
<% end %>

<% end %>

<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#
# CBRAIN Project
#
# Copyright (C) 2020
# The Royal Institution for the Advancement of Learning
# McGill University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#


class AddInputsReadonlyToToolConfig < ActiveRecord::Migration[5.0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add license header. Check other migration for examples.

def change
add_column :tool_configs, :inputs_readonly, :boolean, default: false
end
end
3 changes: 2 additions & 1 deletion BrainPortal/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20201119174821) do
ActiveRecord::Schema.define(version: 20201123133913) do

create_table "access_profiles", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t|
t.string "name", null: false
Expand Down Expand Up @@ -437,6 +437,7 @@
t.string "container_index_location"
t.text "singularity_overlays_specs", limit: 65535
t.string "container_exec_args"
t.boolean "inputs_readonly", default: false
t.index ["bourreau_id"], name: "index_tool_configs_on_bourreau_id", using: :btree
t.index ["tool_id"], name: "index_tool_configs_on_tool_id", using: :btree
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CbrainTask::<%= name %> < <%= (descriptor['custom'] || {})['cbrain:inherit
# The symbol can be passed to methods such as Userfile.find_accessible_by_user().
# Depending on the value, more or less files are allowed to be processed.
def file_access
@_file_access ||= (self.class.properties[:readonly_input_files].present? ? :read : :write)
@_file_access ||= (self.class.properties[:readonly_input_files].present? || self.tool_config.inputs_readonly ? :read : :write)
end

% unless defaults.empty?
Expand Down
2 changes: 2 additions & 0 deletions BrainPortal/spec/boutiques/boutiques_tester_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
# Instantiate a task object
@task = CbrainTask::BoutiquesTest.new
@task.bourreau = execer
@task.tool_config = FactoryBot.create(:tool_config)
@task.user_id, @task.group_id, @task.params = @user.id, @group.id, {}
# Setup for holding the files the user had selected in the UI
@task.params[:interface_userfile_ids] = []
Expand Down Expand Up @@ -443,6 +444,7 @@
@task.bourreau = FactoryBot.create(:bourreau)
@task.user_id, @task.group_id, @task.params = @user.id, @group.id, {}
@task.params[:interface_userfile_ids] = []
@task.tool_config = FactoryBot.create(:tool_config)
# Generate some userfiles for testing
@f1, @f2, @f3 = @addUserFile.('f1.cpp',@task,false), @addUserFile.('f2.java',@task,false), @addUserFile.('f3.j',@task,false)
end
Expand Down