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)
|
def role_for_project(project)
|
||||||
# No role on archived projects
|
# No role on archived projects
|
||||||
return nil unless project && project.active?
|
return nil unless project && project.active?
|
||||||
# Find project membership
|
if logged?
|
||||||
membership = memberships.detect {|m| m.project_id == project.id}
|
# Find project membership
|
||||||
if membership
|
membership = memberships.detect {|m| m.project_id == project.id}
|
||||||
membership.role
|
if membership
|
||||||
elsif logged?
|
membership.role
|
||||||
Role.non_member
|
else
|
||||||
|
@role_non_member ||= Role.non_member
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Role.anonymous
|
@role_anonymous ||= Role.anonymous
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue