Class: Fe::ReferenceSheet
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Fe::ReferenceSheet
- Includes:
- AASM, AccessKeyGenerator, AnswerSheetConcern
- Defined in:
- app/models/fe/reference_sheet.rb
Instance Attribute Summary collapse
-
#allow_quiet_reference_email_changes ⇒ Object
Returns the value of attribute allow_quiet_reference_email_changes.
Instance Method Summary collapse
- #all_affecting_questions_answered ⇒ Object
- #computed_visibility_cache_key ⇒ Object
- #display_type ⇒ Object
- #email_sent? ⇒ Boolean
- #frozen? ⇒ Boolean
- #name ⇒ Object
- #optional? ⇒ Boolean
-
#question_sheet ⇒ Object
Can’t rely on answer_sheet’s implementation for old reference’s that might have id’s that may match an application id.
- #question_sheet_ids ⇒ Object
- #question_sheets ⇒ Object
- #reference ⇒ Object
- #reference? ⇒ Boolean
- #required? ⇒ Boolean
-
#send_invite(host) ⇒ Object
send email invite.
- #to_s ⇒ Object
- #update_visible(page = nil) ⇒ Object
Methods included from AccessKeyGenerator
Methods included from AnswerSheetConcern
#answers_by_question, #collat_title, #complete?, #completely_filled_out?, #has_answer_for?, #languages, #pages, #percent_complete, #question_sheets_all_reference_elements
Instance Attribute Details
#allow_quiet_reference_email_changes ⇒ Object
Returns the value of attribute allow_quiet_reference_email_changes.
10 11 12 |
# File 'app/models/fe/reference_sheet.rb', line 10 def allow_quiet_reference_email_changes @allow_quiet_reference_email_changes end |
Instance Method Details
#all_affecting_questions_answered ⇒ Object
187 188 189 190 |
# File 'app/models/fe/reference_sheet.rb', line 187 def all_affecting_questions_answered return false unless question question.visibility_affecting_questions.all? { |q| q.has_response?(applicant_answer_sheet) } end |
#computed_visibility_cache_key ⇒ Object
91 92 93 94 95 96 97 |
# File 'app/models/fe/reference_sheet.rb', line 91 def computed_visibility_cache_key return @computed_visibility_cache_key if @computed_visibility_cache_key return nil unless question # keep from crashing for tests answers = Fe::Answer.where(question_id: question.visibility_affecting_element_ids, answer_sheet_id: applicant_answer_sheet) answers.collect(&:cache_key_with_version).join('/') end |
#display_type ⇒ Object
175 176 177 |
# File 'app/models/fe/reference_sheet.rb', line 175 def display_type question.label.split(/:| \(/).first end |
#email_sent? ⇒ Boolean
115 |
# File 'app/models/fe/reference_sheet.rb', line 115 def email_sent?() !self.email_sent_at.nil? end |
#frozen? ⇒ Boolean
111 112 113 |
# File 'app/models/fe/reference_sheet.rb', line 111 def frozen? !%w(started created).include?(self.status) end |
#name ⇒ Object
146 147 148 |
# File 'app/models/fe/reference_sheet.rb', line 146 def name [first_name, last_name].join(' ') end |
#optional? ⇒ Boolean
179 180 181 |
# File 'app/models/fe/reference_sheet.rb', line 179 def optional? question.try(:hidden?, applicant_answer_sheet) end |
#question_sheet ⇒ Object
Can’t rely on answer_sheet’s implementation for old reference’s that might have id’s that may match an application id
163 164 165 |
# File 'app/models/fe/reference_sheet.rb', line 163 def question_sheet question_sheet_ref end |
#question_sheet_ids ⇒ Object
171 172 173 |
# File 'app/models/fe/reference_sheet.rb', line 171 def question_sheet_ids [question_sheet_id].compact end |
#question_sheets ⇒ Object
167 168 169 |
# File 'app/models/fe/reference_sheet.rb', line 167 def question_sheets [question_sheet_ref] end |
#reference ⇒ Object
150 151 152 |
# File 'app/models/fe/reference_sheet.rb', line 150 def reference self end |
#reference? ⇒ Boolean
158 159 160 |
# File 'app/models/fe/reference_sheet.rb', line 158 def reference? true end |
#required? ⇒ Boolean
183 184 185 |
# File 'app/models/fe/reference_sheet.rb', line 183 def required? question.required?(applicant_answer_sheet) && !optional? end |
#send_invite(host) ⇒ Object
send email invite
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'app/models/fe/reference_sheet.rb', line 118 def send_invite(host) 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: host)}).deliver_now # 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: host)}).deliver_now self.email_sent_at = Time.now self.save(validate: false) true end |
#to_s ⇒ Object
154 155 156 |
# File 'app/models/fe/reference_sheet.rb', line 154 def to_s name end |
#update_visible(page = nil) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/models/fe/reference_sheet.rb', line 99 def update_visible(page = nil) if visibility_cache_key == computed_visibility_cache_key visible else self.visible = question.visible?(applicant_answer_sheet, page) self.visibility_cache_key = computed_visibility_cache_key # save only these columns and don't check validations, but do record updated_at # as it is significant enough of an event that we probably want that to set updated_at Fe::ReferenceSheet.where(id: id).update_all(visibility_cache_key: self.computed_visibility_cache_key, visible: self.visible, updated_at: Time.now) end end |