mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 03:46:39 +08:00
Merge pull request #3038 from okriuchykhin/ok_SCI_5338
Fix projects visibility in the sidebar [SCI-5338]
This commit is contained in:
commit
cda36a59cf
3 changed files with 3 additions and 16 deletions
|
@ -14,7 +14,7 @@ module ProjectsHelper
|
|||
end
|
||||
|
||||
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)
|
||||
records = case view_state.state.dig('projects', 'active', 'sort')
|
||||
when 'new'
|
||||
|
|
|
@ -46,10 +46,8 @@ class Project < ApplicationRecord
|
|||
scope :visible_to, (lambda do |user, team|
|
||||
unless user.is_admin_of_team?(team)
|
||||
left_outer_joins(:user_projects)
|
||||
.where(
|
||||
'visibility = 1 OR user_projects.user_id = :id',
|
||||
id: user.id
|
||||
).group(:id)
|
||||
.where('visibility = 1 OR user_projects.user_id = :id', id: user.id)
|
||||
.group(:id)
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
@ -438,17 +438,6 @@ class User < ApplicationRecord
|
|||
result || []
|
||||
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
|
||||
# is not an owner of the project, user must be also assigned to
|
||||
# module.
|
||||
|
|
Loading…
Add table
Reference in a new issue