Prevent one query per User#member_of? call after r11508 (#13301).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11605 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
734188c0dc
commit
447e15d6cb
|
@ -454,7 +454,7 @@ class User < Principal
|
||||||
|
|
||||||
# Return true if the user is a member of project
|
# Return true if the user is a member of project
|
||||||
def member_of?(project)
|
def member_of?(project)
|
||||||
roles_for_project(project).any? {|role| role.member?}
|
projects.to_a.include?(project)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a hash of user's projects grouped by roles
|
# Returns a hash of user's projects grouped by roles
|
||||||
|
@ -704,6 +704,10 @@ class AnonymousUser < User
|
||||||
UserPreference.new(:user => self)
|
UserPreference.new(:user => self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def member_of?(project)
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
# Anonymous user can not be destroyed
|
# Anonymous user can not be destroyed
|
||||||
def destroy
|
def destroy
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in New Issue