mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 22:24:23 +08:00
Merge pull request #8688 from artoscinote/ma_SCI_12146
Fix viewable_by_user scope [SCI-12146]
This commit is contained in:
commit
1419ec1d98
1 changed files with 4 additions and 3 deletions
|
@ -27,12 +27,13 @@ module Shareable
|
|||
end
|
||||
|
||||
scope :viewable_by_user, lambda { |user, teams = user.current_team|
|
||||
teams = Team.where(id: teams.id) if teams.is_a?(Team) # handle single team
|
||||
readable_ids = if permission_class == StorageLocation
|
||||
readable_by_user(user).where(team: teams).pluck(:id)
|
||||
elsif teams.permission_granted?(user, TeamPermissions::MANAGE)
|
||||
where(team: teams).pluck(:id)
|
||||
else
|
||||
with_granted_permissions(user, "#{permission_class.name}Permissions::READ".constantize, teams).pluck(:id)
|
||||
with_granted_permissions(user, "#{permission_class.name}Permissions::READ".constantize, teams).or(
|
||||
where(team: teams.with_granted_permissions(user, TeamPermissions::MANAGE))
|
||||
).pluck(:id)
|
||||
end
|
||||
shared_with_team_ids = joins(:team_shared_objects, :team).where(team_shared_objects: { team: teams }).pluck(:id)
|
||||
globally_shared_ids =
|
||||
|
|
Loading…
Add table
Reference in a new issue