Class: Qe::ReferenceSheet

Inherits:
AnswerSheet
  • Object
show all
Defined in:
app/models/qe/reference_sheet.rb

Instance Method Summary collapse

Methods inherited from AnswerSheet

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

Instance Method Details

#display_typeObject



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

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

#email_sent?Boolean



74
# File 'app/models/qe/reference_sheet.rb', line 74

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

#frozen?Boolean



70
71
72
# File 'app/models/qe/reference_sheet.rb', line 70

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

#generate_access_keyObject



66
67
68
# File 'app/models/qe/reference_sheet.rb', line 66

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

#nameObject



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

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

#proc_methodObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/models/qe/reference_sheet.rb', line 42

def proc_method

  # state :completed, :enter => Proc.new {|ref|
  #                               ref.submitted_at = Time.now
  #                               # SpReferenceMailer.deliver_completed(ref)
  #                               # SpReferenceMailer.deliver_completed_confirmation(ref)
  #                               ref.applicant_answer_sheet.complete(ref)
  #                             }

   = Time.now
  # SpReferenceMailer.deliver_completed(ref)
  # SpReferenceMailer.deliver_completed_confirmation(ref)
  ref.applicant_answer_sheet.completed(ref)
  # done
end

#referenceObject



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

def reference
  self
end

#reference?Boolean



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

def reference?
  true  
end

#required?Boolean



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

def required?
  question.required?(applicant_answer_sheet)
end

#send_inviteObject

send email invite



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'app/models/qe/reference_sheet.rb', line 77

def send_invite    
  return if self.email.blank?
  
  application = self.applicant_answer_sheet
  
  Notifier.deliver_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])})
  # Send notification to applicant
  Notifier.deliver_notification(applicant_answer_sheet.email, # RECIPIENTS
                                Questionnaire.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])})

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

#to_sObject



113
114
115
# File 'app/models/qe/reference_sheet.rb', line 113

def to_s
  name
end