Class: AllocationNotification

Inherits:
VRCron
  • Object
show all
Defined in:
crons/allocation_notification.rb

Overview

Notifies all Users marked as allocation users that they should set or confirm their allocation

Cron Job:

Class Method Summary (collapse)

Methods inherited from VRCron

#cron, cronjobs, each, vrcron_name, vrcron_schedule, vrcron_type

Class Method Details

+ (Boolean) cron

Method invoked when called by the Scheduler job

Returns:

  • (Boolean)

    Return is a pass-through of notifyAll - True on success, False otherwise



24
25
26
# File 'crons/allocation_notification.rb', line 24

def self.cron()
	return notifyAll()
end

+ (Boolean) notifyAll

For all Users marked as using allocation, notify that a MonthlyAllocation was automatically set or needs to be confirmed This job should only run after AllocationPreset which will automatically set a MonthlyAllocation for that User if possible

Returns:

  • (Boolean)

    True on success, False otherwise



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'crons/allocation_notification.rb', line 32

def self.notifyAll()
	users = User.all(:useAllocation => true, :active => true)

	users.each do |u|
		next if (!u.allocation.nil? && !u.allocation.wasAutoSet)

		@name = u.name.split(" ").first
		@autoset = !u.allocation.nil? && u.allocation.wasAutoSet
		if(u.allocation.nil?)
			@autosetAlloc = 0
		else
			@autosetAlloc = u.allocation.allocation
		end

		@vrurl = getSetting('VR_ROOT').to_s
		renderer = ERB.new(File.open("views/emails/allocEmail.erb", "rb").read)
		body = renderer.result(binding)
		
		recips = u.email

		fromEmail = getSetting('VR_NOREPLY_EMAIL')
		Pony.mail(:to => recips, :from => fromEmail, :subject => "Vulnreport Allocation for #{Date.today.strftime('%B')}", :html_body => body)
	end

	return true
end