Merge pull request #4845 from aignatov-bio/ai-sci-7758-fix-user-designation-on-creation

Fix user designation on task creation [SCI-7758]
This commit is contained in:
aignatov-bio 2023-01-17 15:12:46 +01:00 committed by GitHub
commit 5cbaf83067
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View file

@ -47,9 +47,9 @@ class MyModulesController < ApplicationController
if my_module_tags_params[:tag_ids].present?
@my_module.tags << @experiment.project.tags.where(id: JSON.parse(my_module_tags_params[:tag_ids]))
end
if my_module_designated_users_params[:user_ids].present? && can_manage_my_module_designated_users?(@my_module)
if my_module_designated_users_params[:user_ids].present? && can_designate_users_to_new_task?(@experiment)
@my_module.designated_users << @experiment.users.where(id: my_module_designated_users_params[:user_ids])
elsif !can_manage_my_module_designated_users?(@my_module)
elsif !can_designate_users_to_new_task?(@experiment)
@my_module.designated_users << current_user
end
@my_module.save!

View file

@ -84,6 +84,10 @@ Canaid::Permissions.register_for(Experiment) do
can :move_experiment do |user, experiment|
experiment.permission_granted?(user, ExperimentPermissions::MANAGE)
end
can :designate_users_to_new_task do |user, experiment|
experiment.permission_granted?(user, MyModulePermissions::DESIGNATED_USERS_MANAGE)
end
end
Canaid::Permissions.register_for(Protocol) do

View file

@ -55,7 +55,7 @@
</div>
</div>
</div>
<% if can_manage_my_module_designated_users?(@my_module)%>
<% if can_designate_users_to_new_task?(@experiment) %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<label><%= t('experiments.canvas.new_my_module_modal.assigned_users') %></label>