Merge pull request #7818 from artoscinote/ma_SCI_11005

Fix project export permission checks [SCI-11005]
This commit is contained in:
Martin Artnik 2024-08-27 14:32:48 +02:00 committed by GitHub
commit 6260ca7a7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -52,13 +52,13 @@ class TeamZipExportJob < ZipExportJob
# Include all experiments
ex_idx = ex_archive_idx = 0
project.experiments.find_each do |experiment|
project.experiments.readable_by_user(@user).find_each do |experiment|
idx = experiment.archived ? (ex_archive_idx += 1) : (ex_idx += 1)
experiment_path = make_model_dir(project_path, experiment, idx)
# Include all modules
mod_pos = mod_archive_pos = 0
experiment.my_modules.order(:workflow_order).find_each do |my_module|
experiment.my_modules.readable_by_user(@user).order(:workflow_order).find_each do |my_module|
pos = my_module.archived ? (mod_archive_pos += 1) : (mod_pos += 1)
my_module_path = make_model_dir(experiment_path, my_module, pos)

View file

@ -37,6 +37,10 @@ class RepositorySnapshot < RepositoryBase
.where(my_module: { experiments: { project: project } })
}
scope :readable_by_user, lambda { |user|
where(my_module_id: MyModule.readable_by_user(user).select(:id))
}
def self.create_preliminary!(repository, my_module, created_by = nil)
created_by ||= repository.created_by
create!(