[SCI-6322] use correct user when creating templates, create assignment on experiments and tasks

This commit is contained in:
Miha Mencin 2021-12-02 16:54:43 +01:00
parent c746d6b761
commit b964bfd31e
2 changed files with 10 additions and 3 deletions

View file

@ -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_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

View file

@ -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?