-
Notifications
You must be signed in to change notification settings - Fork 482
/
fit_cohort_view_serializer.rb
82 lines (70 loc) · 1.62 KB
/
fit_cohort_view_serializer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class Api::V1::Pd::FitCohortViewSerializer < ActiveModel::Serializer
include Pd::Application::ActiveApplicationModels
attributes(
:id,
:type,
:date_accepted,
:applicant_name,
:district_name,
:school_name,
:email,
:assigned_workshop,
:registered_workshop,
:assigned_fit,
:registered_fit,
:accepted_fit,
:registered_fit_submission_time,
:role,
:status,
:locked,
:regional_partner_name,
:course_name,
:form_data,
:notes,
:notes_2,
:notes_3,
:notes_4,
:notes_5,
)
def type
object.class.name
end
def assigned_workshop
object.workshop_date_and_location
end
def registered_workshop
object.try(:registered_workshop?)
end
def assigned_fit
object.try(:fit_workshop_date_and_location)
end
def registered_fit
object.try(:registered_fit_workshop?)
end
def registered_fit_submission_time
object.try(FIT_WEEKEND_REGISTRATION_SYMBOL).try(:created_at)
end
def fit_assigned_at_registration
object.try(FIT_WEEKEND_REGISTRATION_SYMBOL).try(:fit_city)
end
def accepted_fit
object.try(FIT_WEEKEND_REGISTRATION_SYMBOL).try(:accepted_seat_simplified)
end
def role
if object.is_a? Pd::Application::Teacher1819Application
'Teacher'
elsif object.is_a? Pd::Application::Facilitator1819Application
'New Facilitator'
elsif object.user.try {|user| user.regional_partners.any?}
'Regional Partner'
else
'Lead Facilitator'
end
end
def locked
object.locked?
end
def form_data
object.try(FIT_WEEKEND_REGISTRATION_SYMBOL).try(:form_data_hash)
end
end