Module: EffectiveWorkExperienceSummary
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_work_experience_summary.rb
Overview
EffectiveWorkExperienceSummary
Mark your model with effective_work_experience_summary to get all the includes
The summary of an intern's work experience for one period, usually 3 months.
Submitted by the intern, and reviewed by their mentor.
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary
collapse
Instance Method Details
#can_visit_step?(current_step) ⇒ Boolean
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 175
def can_visit_step?(current_step)
return false if current_user == user && intern_steps.exclude?(current_step)
return false if current_user == mentor && mentor_steps.exclude?(current_step)
if was_submitted?
return false if [:start, :records, :projects, :submit].include?(current_step)
end
if was_reviewed?
return [:review, :reviewed].include?(current_step)
end
can_revisit_completed_steps(current_step)
end
|
#intern_steps ⇒ Object
The intern completes the first half of the wizard, the mentor completes the second half
144
145
146
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 144
def intern_steps
[:start, :records, :projects, :submit, :submitted, :reviewed]
end
|
#mentor_present? ⇒ Boolean
An intern with an outside mentor has no mentor user. Their summaries are automatically reviewed.
171
172
173
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 171
def mentor_present?
mentor.present? || user.try(:work_experience_outside_mentor?).present?
end
|
#mentor_steps ⇒ Object
148
149
150
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 148
def mentor_steps
[:submitted, :review, :reviewed]
end
|
#months ⇒ Object
The first day of each month in this summary period
161
162
163
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 161
def months
@months ||= start_on.all_quarter.to_a.select { |month| month.day == 1 }
end
|
#period ⇒ Object
165
166
167
168
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 165
def period
return if start_on.blank?
"#{months.first.strftime('%B %Y')} to #{months.last.strftime('%B %Y')}"
end
|
#recommendations ⇒ Object
152
153
154
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 152
def recommendations
Array(EffectiveWorkExperience.recommendations)
end
|
#review! ⇒ Object
244
245
246
247
248
249
250
251
252
253
254
255
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 244
def review!
wizard_steps[:review] ||= Time.zone.now
wizard_steps[:reviewed] = Time.zone.now
unless was_reviewed? || mentor.blank? || importing
after_commit { EffectiveWorkExperience.mailer_class.work_experience_summary_reviewed(self).deliver }
end
work_experience_records.reject(&:was_reviewed?).each { |work_experience_record| work_experience_record.reviewed! }
reviewed!
end
|
#status_label ⇒ Object
196
197
198
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 196
def status_label
(status_was || status).to_s.gsub('_', ' ').titleize
end
|
#submit! ⇒ Object
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 225
def submit!
raise('already submitted') if was_submitted?
wizard_steps[:submit] ||= Time.zone.now
wizard_steps[:submitted] = Time.zone.now
if mentor.present? && !importing
after_commit { EffectiveWorkExperience.mailer_class.work_experience_summary_submitted(self).deliver }
end
work_experience_records.reject(&:was_submitted?).each { |work_experience_record| work_experience_record.submitted! }
submitted!
review! if mentor.blank?
true
end
|
#summary ⇒ Object
200
201
202
203
204
205
206
207
208
209
210
211
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 200
def summary
case status_was
when 'draft'
"Work experience summary has not yet been submitted."
when 'submitted'
"Work experience summary has been submitted."
when 'reviewed'
"Work experience summary has been reviewed."
else
raise("unexpected status #{status}")
end.html_safe
end
|
#summary_months ⇒ Object
156
157
158
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 156
def summary_months
(EffectiveWorkExperience.summary_months || 3)
end
|
#to_s ⇒ Object
139
140
141
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 139
def to_s
start_on&.strftime('%B %Y') || model_name.human
end
|
#total_hours_to_date ⇒ Object
192
193
194
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 192
def total_hours_to_date
user.work_experience_total_hours_to_date(month: end_on)
end
|
#work_experience_projects ⇒ Object
221
222
223
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 221
def work_experience_projects
@work_experience_projects ||= user.work_experience_projects.during(months)
end
|
#work_experience_records ⇒ Object
217
218
219
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 217
def work_experience_records
@work_experience_records ||= user.work_experience_records.where(month: months)
end
|
#work_experience_subcategories ⇒ Object
213
214
215
|
# File 'app/models/concerns/effective_work_experience_summary.rb', line 213
def work_experience_subcategories
Effective::WorkExperienceSubcategory.all.sorted
end
|