Fix access filter and published by column [SCI-7988] (#5030)

This commit is contained in:
ajugo 2023-02-27 12:08:45 +01:00 committed by GitHub
parent 5de5d64be5
commit d26edb08df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -70,7 +70,7 @@ class LoadFromRepositoryProtocolsDatatable < CustomDatatable
'ON "protocol_protocol_keywords"."protocol_id" = "protocols"."id"')
.joins('LEFT OUTER JOIN "protocol_keywords"'\
'ON "protocol_protocol_keywords"."protocol_keyword_id" = "protocol_keywords"."id"')
.joins('LEFT OUTER JOIN users ON users.id = protocols.added_by_id').active
.joins('LEFT OUTER JOIN users ON users.id = protocols.published_by_id').active
records.group('"protocols"."id"')
end

View file

@ -118,10 +118,7 @@ class ProtocolsDatatable < CustomDatatable
records = records.where('protocols.updated_at > ?', params[:modified_on_from]) if params[:modified_on_from].present?
records = records.where('protocols.updated_at < ?', params[:modified_on_to]) if params[:modified_on_to].present?
records = records.where(protocols: { published_by_id: params[:published_by] }) if params[:published_by].present?
if params[:members].present?
records = records.joins(:user_assignments).where(user_assignments: { user_id: params[:members] })
end
records = records.where(all_user_assignments: { user_id: params[:members] }) if params[:members].present?
if params[:archived_on_from].present?
records = records.where('protocols.archived_on > ?', params[:archived_on_from])
@ -162,7 +159,7 @@ class ProtocolsDatatable < CustomDatatable
records = records.joins('LEFT OUTER JOIN "users" "archived_users"
ON "archived_users"."id" = "protocols"."archived_by_id"')
records = records.joins('LEFT OUTER JOIN "users" ON "users"."id" = "protocols"."added_by_id"')
records = records.joins('LEFT OUTER JOIN "users" ON "users"."id" = "protocols"."published_by_id"')
records = @type == :archived ? records.archived : records.active