mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
Fixed permission issues when moving experiment [SCI-6257] (#3655)
* Fixed permission issues when moving experiment [SCI-6257] * Copy fixes [SCI-6248] * Use canaid helper instead of permission_granted [SCI-6257] * Fixes [SCI-6257]
This commit is contained in:
parent
1c3a2aa0a7
commit
a6c61c2b4e
3 changed files with 18 additions and 7 deletions
|
@ -205,10 +205,10 @@ class Experiment < ApplicationRecord
|
|||
# team and not archived), all users assigned on experiment.project has
|
||||
# to be assigned on such project
|
||||
def movable_projects(current_user)
|
||||
current_user.projects
|
||||
.where.not(id: project_id)
|
||||
.where(archived: false, team: project.team)
|
||||
.with_user_permission(current_user, ProjectPermissions::EXPERIMENTS_CREATE)
|
||||
project.team.projects.active
|
||||
.where.not(id: project_id)
|
||||
.where(archived: false)
|
||||
.with_granted_permissions(current_user, ProjectPermissions::EXPERIMENTS_CREATE)
|
||||
end
|
||||
|
||||
def permission_parent
|
||||
|
|
|
@ -18,6 +18,11 @@ module Experiments
|
|||
def call
|
||||
return self unless valid?
|
||||
|
||||
unless can_create_project_experiments?(@user, @project)
|
||||
@errors[:main] = I18n.t('move_to_project_service.project_permission_error')
|
||||
return self
|
||||
end
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
@exp.project = @project
|
||||
@exp.my_modules.each do |my_module|
|
||||
|
@ -32,7 +37,7 @@ module Experiments
|
|||
sync_user_assignments(@exp)
|
||||
rescue StandardError
|
||||
if @exp.valid?
|
||||
@errors[:main] = "Don't have permission for tasks manage"
|
||||
@errors[:main] = I18n.t('move_to_project_service.my_modules_permission_error')
|
||||
else
|
||||
@errors.merge!(@exp.errors.to_hash)
|
||||
end
|
||||
|
|
|
@ -1109,12 +1109,13 @@ en:
|
|||
current_project: '(current project)'
|
||||
move:
|
||||
modal_title: 'Move experiment %{experiment}'
|
||||
notice: 'Moving is possible only to projects that contain same (or additional) users.'
|
||||
notice: 'Moving is possible to projects, where you have permissions to create experiments and tasks.'
|
||||
label_title: 'Move'
|
||||
modal_submit: 'Move'
|
||||
success_flash: "Successfully moved experiment %{experiment}"
|
||||
error_flash: ' Could not move the experiment. Experiment name is already in use. '
|
||||
no_projects: 'No projects to move this experiment to.'
|
||||
task_permission: 'No permission: You don’t have edit access to all experiment tasks.'
|
||||
no_projects: 'No projects: You don’t have edit access to any other projects.'
|
||||
canvas:
|
||||
archive_confirm: "Are you sure to archive this experiment?"
|
||||
actions: 'Actions'
|
||||
|
@ -2504,6 +2505,11 @@ en:
|
|||
from_project: "%{user_role} [from project]"
|
||||
from_experiment: "%{user_role} [from experiment]"
|
||||
experiment_select_role: "Change experiment role"
|
||||
|
||||
move_to_project_service:
|
||||
project_permission_error: "No permission to create experiments at project"
|
||||
my_modules_permission_error: "No manage permissions on tasks"
|
||||
|
||||
access_permissions:
|
||||
create:
|
||||
success:
|
||||
|
|
Loading…
Reference in a new issue