mirror of
https://github.com/redmine/redmine.git
synced 2025-11-09 06:46:01 +01:00
Speeds up rendering of the project list for users who belong to hundreds of projects.
git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -108,6 +108,11 @@ class Principal < ActiveRecord::Base
|
|||||||
|
|
||||||
before_create :set_default_empty_values
|
before_create :set_default_empty_values
|
||||||
|
|
||||||
|
def reload(*args)
|
||||||
|
@project_ids = nil
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def name(formatter = nil)
|
def name(formatter = nil)
|
||||||
to_s
|
to_s
|
||||||
end
|
end
|
||||||
@@ -124,9 +129,14 @@ class Principal < ActiveRecord::Base
|
|||||||
Principal.visible(user).where(:id => id).first == self
|
Principal.visible(user).where(:id => id).first == self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return true if the principal is a member of project
|
# Returns true if the principal is a member of project
|
||||||
def member_of?(project)
|
def member_of?(project)
|
||||||
projects.to_a.include?(project)
|
project.is_a?(Project) && project_ids.include?(project.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns an array of the project ids that the principal is a member of
|
||||||
|
def project_ids
|
||||||
|
@project_ids ||= super.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=>(principal)
|
def <=>(principal)
|
||||||
|
|||||||
Reference in New Issue
Block a user