Slight optimization in User#role_for_project.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@928 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
fde4a42e2a
commit
f80f04e379
|
@ -178,14 +178,16 @@ class User < ActiveRecord::Base
|
|||
def role_for_project(project)
|
||||
# No role on archived projects
|
||||
return nil unless project && project.active?
|
||||
if logged?
|
||||
# Find project membership
|
||||
membership = memberships.detect {|m| m.project_id == project.id}
|
||||
if membership
|
||||
membership.role
|
||||
elsif logged?
|
||||
Role.non_member
|
||||
else
|
||||
Role.anonymous
|
||||
@role_non_member ||= Role.non_member
|
||||
end
|
||||
else
|
||||
@role_anonymous ||= Role.anonymous
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue