Remove visibility condition from projects scope [SCI-6188] (#3667)

Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
aignatov-bio 2021-11-17 10:16:54 +01:00 committed by GitHub
parent 8609b84131
commit 4b79ba209d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,9 +62,9 @@ class Project < ApplicationRecord
scope :visible_to, (lambda do |user, team|
unless user.is_admin_of_team?(team)
left_outer_joins(:user_assignments)
.where('visibility = 1 OR user_assignments.user_id = :id', id: user.id)
.group(:id)
left_outer_joins(user_assignments: :user_role)
.where(user_assignments: { user: user })
.where('? = ANY(user_roles.permissions)', ProjectPermissions::READ)
end
end)