Class: JobMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/job_mailer.rb

Instance Method Summary collapse

Instance Method Details

#notify_added_employees(job, added_people) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/mailers/job_mailer.rb', line 45

def notify_added_employees(job, added_people)
  @job = job
  if added_people.present?
    added_people.each do |user|
      options = {:to => user.email,
                 :cc => job.supervisors.collect { |user| user.email },
                 :subject => "GA Jobs - you've been added to " + job.title,
                 :date => Time.now,
      }
      mail(options).deliver
    end
  end

end

#notify_hr(job, added_people, removed_people) ⇒ Object



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
# File 'app/mailers/job_mailer.rb', line 5

def notify_hr(job, added_people, removed_people)
  message = "Action required: please update billing records<br/>"

  if added_people.present?
    message += "The following people were added<br/>"
    added_people.each do |user|
      message += "#{user.human_name}<br/>"
    end
  end
  message += "<br/>"

  if removed_people.present?
    message += "The following people were removed<br/>"
    removed_people.each do |user|
      message += "#{user.human_name}<br/>"
    end
  end

  if job.id.present?
    url_label = "View this job"
    url = Rails.application.routes.url_helpers.edit_job_url(job, :host => "whiteboard.sv.cmu.edu")
  else
    url_label = ""
    url = ""
  end

  options = {:to => "[email protected]",
             :subject => "GA Jobs - people assigned to a project changed - " + job.title,
             :message => message,
             :url_label => url_label,
             :url => url,
             :template_path => 'generic_mailer',
             :template_name => 'email',
             :date => Time.now
  }
  GenericMailer.email(options).deliver

end

#notify_removed_employees(job, removed_people) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/mailers/job_mailer.rb', line 60

def notify_removed_employees(job, removed_people)
  message = "You've been removed from the project " + job.title

  if removed_people.present?
    removed_people.each do |user|
      options = {:to => user.email,
                 :cc => job.supervisors.collect { |user| user.email },
                 :subject => "GA Jobs - you've been removed from " + job.title,
                 :message => message,
                 :date => Time.now,
                 :template_path => 'generic_mailer',
                 :template_name => 'email'
      }
      GenericMailer.email(options).deliver
    end
  end

end