@@ -108,6 +108,11 class Principal < ActiveRecord::Base | |||||
108 |
|
108 | |||
109 | before_create :set_default_empty_values |
|
109 | before_create :set_default_empty_values | |
110 |
|
110 | |||
|
111 | def reload(*args) | |||
|
112 | @project_ids = nil | |||
|
113 | super | |||
|
114 | end | |||
|
115 | ||||
111 | def name(formatter = nil) |
|
116 | def name(formatter = nil) | |
112 | to_s |
|
117 | to_s | |
113 | end |
|
118 | end | |
@@ -124,9 +129,14 class Principal < ActiveRecord::Base | |||||
124 | Principal.visible(user).where(:id => id).first == self |
|
129 | Principal.visible(user).where(:id => id).first == self | |
125 | end |
|
130 | end | |
126 |
|
131 | |||
127 | # Return true if the principal is a member of project |
|
132 | # Returns true if the principal is a member of project | |
128 | def member_of?(project) |
|
133 | def member_of?(project) | |
129 |
project |
|
134 | project.is_a?(Project) && project_ids.include?(project.id) | |
|
135 | end | |||
|
136 | ||||
|
137 | # Returns an array of the project ids that the principal is a member of | |||
|
138 | def project_ids | |||
|
139 | @project_ids ||= super.freeze | |||
130 | end |
|
140 | end | |
131 |
|
141 | |||
132 | def <=>(principal) |
|
142 | def <=>(principal) |
General Comments 0
You need to be logged in to leave comments.
Login now