mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-30 20:23:14 +08:00
Please the Hound
This commit is contained in:
parent
3313d14316
commit
86be639a7c
1 changed files with 3 additions and 3 deletions
|
@ -254,7 +254,7 @@ class User < ActiveRecord::Base
|
|||
query = Project.all.joins(:user_projects)
|
||||
sql = 'projects.team_id IN (SELECT DISTINCT team_id ' \
|
||||
'FROM user_teams WHERE user_teams.user_id = :user_id)'
|
||||
if team_id == 0 || !user_teams.find_by(team_id: team_id).try(:admin?)
|
||||
if team_id.zero? || !user_teams.find_by(team_id: team_id).try(:admin?)
|
||||
# Admins see all projects of team
|
||||
sql += ' AND (projects.visibility=1 OR user_projects.user_id=:user_id)'
|
||||
end
|
||||
|
@ -275,13 +275,13 @@ class User < ActiveRecord::Base
|
|||
if team_id > 0
|
||||
result = query
|
||||
.where('projects.team_id = ?', team_id)
|
||||
.where(sql,user_id: id, archived: archived)
|
||||
.where(sql, user_id: id, archived: archived)
|
||||
.order(sort)
|
||||
.distinct
|
||||
.group_by(&:team)
|
||||
else
|
||||
result = query
|
||||
.where(sql,user_id: id, archived: archived)
|
||||
.where(sql, user_id: id, archived: archived)
|
||||
.order(sort)
|
||||
.distinct
|
||||
.group_by(&:team)
|
||||
|
|
Loading…
Reference in a new issue