From b964bfd31e278560cf52eb6733954478f1b42ef1 Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Thu, 2 Dec 2021 16:54:43 +0100 Subject: [PATCH] [SCI-6322] use correct user when creating templates, create assignment on experiments and tasks --- app/services/team_importer.rb | 8 +++++++- app/services/templates_service.rb | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/services/team_importer.rb b/app/services/team_importer.rb index 7bc0a14f6..c62152091 100644 --- a/app/services/team_importer.rb +++ b/app/services/team_importer.rb @@ -189,7 +189,13 @@ class TeamImporter end update_smart_annotations_in_project(project) - + + # handle the permissions for newly created experiment + user = User.find(user_id) + UserAssignments::GenerateUserAssignmentsJob.perform_later(experiment, user) + experiment.my_modules.each do |my_module| + UserAssignments::GenerateUserAssignmentsJob.perform_later(my_module, user) + end puts "Imported experiment: #{experiment.id}" return experiment end diff --git a/app/services/templates_service.rb b/app/services/templates_service.rb index 78a4d20fe..8bdb18caf 100644 --- a/app/services/templates_service.rb +++ b/app/services/templates_service.rb @@ -26,8 +26,9 @@ class TemplatesService ) end end - owner = tmpl_project.user_projects - .where(role: 'owner') + owner_role_id = UserRole.find_by(name: I18n.t('user_roles.predefined.owner')).id + owner = tmpl_project.user_assignments + .where(user_role_id: owner_role_id) .order(:created_at) .first&.user return unless owner.present?