Class: Fe::ReferenceSheet

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AASM, AccessKeyGenerator, AnswerSheetConcern
Defined in:
app/models/fe/reference_sheet.rb

Instance Method Summary collapse

Methods included from AccessKeyGenerator

#generate_access_key

Methods included from AnswerSheetConcern

#answers_by_question, #collat_title, #complete?, #completely_filled_out?, #has_answer_for?, #languages, #pages, #percent_complete

Instance Method Details

#display_typeObject



151
152
153
# File 'app/models/fe/reference_sheet.rb', line 151

def display_type
  question.label.split(/:| \(/).first
end

#email_sent?Boolean

Returns:

  • (Boolean)


86
# File 'app/models/fe/reference_sheet.rb', line 86

def email_sent?() !self.email_sent_at.nil? end

#frozen?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'app/models/fe/reference_sheet.rb', line 82

def frozen?
  !%w(started created).include?(self.status)
end

#nameObject



117
118
119
# File 'app/models/fe/reference_sheet.rb', line 117

def name
  [first_name, last_name].join(' ')
end

#question_sheetObject

Can’t rely on answer_sheet’s implementation for old reference’s that might have id’s that may match an application id



138
139
140
# File 'app/models/fe/reference_sheet.rb', line 138

def question_sheet
  QuestionSheet.find(question.related_question_sheet_id) if question && question.related_question_sheet_id
end

#question_sheet_idsObject



147
148
149
# File 'app/models/fe/reference_sheet.rb', line 147

def question_sheet_ids
  [question_sheet.try(:id)].compact
end

#question_sheetsObject

Can’t rely on answer_sheet’s implementation for old reference’s that might have id’s that may match an application id



143
144
145
# File 'app/models/fe/reference_sheet.rb', line 143

def question_sheets
  [question_sheet]
end

#referenceObject



121
122
123
# File 'app/models/fe/reference_sheet.rb', line 121

def reference
  self
end

#reference?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'app/models/fe/reference_sheet.rb', line 133

def reference?
  true
end

#required?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'app/models/fe/reference_sheet.rb', line 129

def required?
  question.required?(applicant_answer_sheet)
end

#send_inviteObject

send email invite



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'app/models/fe/reference_sheet.rb', line 89

def send_invite
  return if self.email.blank?

  application = self.applicant_answer_sheet

  Notifier.notification(self.email,
                        Fe.from_email,
                        "Reference Invite",
                        {'reference_full_name' => self.name,
                         'applicant_full_name' => application.applicant.name,
                         'applicant_email' => application.applicant.email,
                         'applicant_home_phone' => application.applicant.phone,
                         'reference_url' => edit_fe_reference_sheet_url(self, :a => self.access_key, :host => ActionMailer::Base.default_url_options[:host])}).deliver
  # Send notification to applicant
  Notifier.notification(applicant_answer_sheet.applicant.email, # RECIPIENTS
                        Fe.from_email, # FROM
                        "Reference Notification to Applicant", # LIQUID TEMPLATE NAME
                        {'applicant_full_name' => applicant_answer_sheet.applicant.name,
                         'reference_full_name' => self.name,
                         'reference_email' => self.email,
                         'application_url' => edit_fe_answer_sheet_url(applicant_answer_sheet, :host => ActionMailer::Base.default_url_options[:host])}).deliver

  self.email_sent_at = Time.now
  self.save(:validate => false)

  true
end

#to_sObject



125
126
127
# File 'app/models/fe/reference_sheet.rb', line 125

def to_s
  name
end