mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-10 05:46:47 +08:00
Fix projects visibility in the sidebar [SCI-5338]
This commit is contained in:
parent
a8991356b5
commit
f43340a849
3 changed files with 3 additions and 16 deletions
|
@ -14,7 +14,7 @@ module ProjectsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def sidebar_folders_tree(team, user)
|
def sidebar_folders_tree(team, user)
|
||||||
records = user.projects_tree(team) + ProjectFolder.inner_folders(team)
|
records = team.projects.active.visible_to(user, team) + ProjectFolder.inner_folders(team)
|
||||||
view_state = team.current_view_state(user)
|
view_state = team.current_view_state(user)
|
||||||
records = case view_state.state.dig('projects', 'active', 'sort')
|
records = case view_state.state.dig('projects', 'active', 'sort')
|
||||||
when 'new'
|
when 'new'
|
||||||
|
|
|
@ -46,10 +46,8 @@ class Project < ApplicationRecord
|
||||||
scope :visible_to, (lambda do |user, team|
|
scope :visible_to, (lambda do |user, team|
|
||||||
unless user.is_admin_of_team?(team)
|
unless user.is_admin_of_team?(team)
|
||||||
left_outer_joins(:user_projects)
|
left_outer_joins(:user_projects)
|
||||||
.where(
|
.where('visibility = 1 OR user_projects.user_id = :id', id: user.id)
|
||||||
'visibility = 1 OR user_projects.user_id = :id',
|
.group(:id)
|
||||||
id: user.id
|
|
||||||
).group(:id)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -438,17 +438,6 @@ class User < ApplicationRecord
|
||||||
result || []
|
result || []
|
||||||
end
|
end
|
||||||
|
|
||||||
def projects_tree(team)
|
|
||||||
result = team.projects
|
|
||||||
unless is_admin_of_team?(team)
|
|
||||||
# Only admins see all projects of the team
|
|
||||||
result = result.joins(:user_projects).where(
|
|
||||||
'visibility=1 OR user_projects.user_id=:user_id', user_id: id
|
|
||||||
)
|
|
||||||
end
|
|
||||||
result.where(archived: false)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Finds all activities of user that is assigned to project. If user
|
# Finds all activities of user that is assigned to project. If user
|
||||||
# is not an owner of the project, user must be also assigned to
|
# is not an owner of the project, user must be also assigned to
|
||||||
# module.
|
# module.
|
||||||
|
|
Loading…
Add table
Reference in a new issue