mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-02 21:51:51 +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)
|
query = Project.all.joins(:user_projects)
|
||||||
sql = 'projects.team_id IN (SELECT DISTINCT team_id ' \
|
sql = 'projects.team_id IN (SELECT DISTINCT team_id ' \
|
||||||
'FROM user_teams WHERE user_teams.user_id = :user_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
|
# Admins see all projects of team
|
||||||
sql += ' AND (projects.visibility=1 OR user_projects.user_id=:user_id)'
|
sql += ' AND (projects.visibility=1 OR user_projects.user_id=:user_id)'
|
||||||
end
|
end
|
||||||
|
@ -275,13 +275,13 @@ class User < ActiveRecord::Base
|
||||||
if team_id > 0
|
if team_id > 0
|
||||||
result = query
|
result = query
|
||||||
.where('projects.team_id = ?', team_id)
|
.where('projects.team_id = ?', team_id)
|
||||||
.where(sql,user_id: id, archived: archived)
|
.where(sql, user_id: id, archived: archived)
|
||||||
.order(sort)
|
.order(sort)
|
||||||
.distinct
|
.distinct
|
||||||
.group_by(&:team)
|
.group_by(&:team)
|
||||||
else
|
else
|
||||||
result = query
|
result = query
|
||||||
.where(sql,user_id: id, archived: archived)
|
.where(sql, user_id: id, archived: archived)
|
||||||
.order(sort)
|
.order(sort)
|
||||||
.distinct
|
.distinct
|
||||||
.group_by(&:team)
|
.group_by(&:team)
|
||||||
|
|
Loading…
Reference in a new issue