Class: Fe::ReferenceSheet

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

Instance Method Summary collapse

Methods included from AnswerSheetConcern

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

Instance Method Details

#display_typeObject



123
124
125
# File 'app/models/fe/reference_sheet.rb', line 123

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

#email_sent?Boolean

Returns:

  • (Boolean)


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

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

#frozen?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/models/fe/reference_sheet.rb', line 58

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

#generate_access_keyObject



54
55
56
# File 'app/models/fe/reference_sheet.rb', line 54

def generate_access_key
  self.access_key = Digest::MD5.hexdigest(email + Time.now.to_s)
end

#nameObject



93
94
95
# File 'app/models/fe/reference_sheet.rb', line 93

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



114
115
116
# File 'app/models/fe/reference_sheet.rb', line 114

def question_sheet
  QuestionSheet.find(question.related_question_sheet_id) if question && question.related_question_sheet_id
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



119
120
121
# File 'app/models/fe/reference_sheet.rb', line 119

def question_sheets
  [question_sheet]
end

#referenceObject



97
98
99
# File 'app/models/fe/reference_sheet.rb', line 97

def reference
  self
end

#reference?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'app/models/fe/reference_sheet.rb', line 109

def reference?
  true
end

#required?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'app/models/fe/reference_sheet.rb', line 105

def required?
  question.required?(applicant_answer_sheet)
end

#send_inviteObject

send email invite



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'app/models/fe/reference_sheet.rb', line 65

def send_invite
  return if self.email.blank?

  application = self.applicant_answer_sheet

  Notifier.notification(self.email,
                        application.email,
                        "Reference Invite",
                        {'reference_full_name' => self.name,
                         'applicant_full_name' => application.name,
                         'applicant_email' => application.email,
                         'applicant_home_phone' => application.phone,
                         'reference_url' => edit_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.email, # RECIPIENTS
                        Fe.from_email, # FROM
                        "Reference Notification to Applicant", # LIQUID TEMPLATE NAME
                        {'applicant_full_name' => applicant_answer_sheet.name,
                         'reference_full_name' => self.name,
                         'reference_email' => self.email,
                         'application_url' => edit_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



101
102
103
# File 'app/models/fe/reference_sheet.rb', line 101

def to_s
  name
end