diff --git a/app/services/team_importer.rb b/app/services/team_importer.rb index 7bc0a14f6..35ae086b9 100644 --- a/app/services/team_importer.rb +++ b/app/services/team_importer.rb @@ -190,6 +190,12 @@ class TeamImporter update_smart_annotations_in_project(project) + # handle the permissions for newly created experiment + user = User.find(user_id) + UserAssignments::GenerateUserAssignmentsJob.perform_now(experiment, user) + experiment.my_modules.find_each do |my_module| + UserAssignments::GenerateUserAssignmentsJob.perform_now(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?