mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-02 21:51:51 +08:00
0eacb91bed
* Renamed 'group_user_role', fixed public project migration [SCI-6234] * Moved public project update inside loop [SCI-6234]
31 lines
910 B
Ruby
31 lines
910 B
Ruby
# frozen_string_literal: true
|
|
|
|
module UserAssignments
|
|
class GroupAssignmentJob < ApplicationJob
|
|
queue_as :high_priority
|
|
|
|
def perform(team, project, assigned_by)
|
|
@team = team
|
|
@assigned_by = assigned_by
|
|
|
|
ActiveRecord::Base.transaction do
|
|
team.users.where.not(id: project.users.pluck(:id)).where.not(id: assigned_by.id).find_each do |user|
|
|
UserAssignment.create!(
|
|
user: user,
|
|
assignable: project,
|
|
user_role: project.default_public_user_role,
|
|
assigned_by: @assigned_by,
|
|
assigned: :automatically
|
|
)
|
|
# make sure all related experiments and my modules are assigned
|
|
UserAssignments::PropagateAssignmentJob.perform_later(
|
|
project,
|
|
user,
|
|
project.default_public_user_role,
|
|
@assigned_by
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|