Commit f5da59a1 authored by Cool Fire's avatar Cool Fire

Fixes for requests

parent 934741e3
......@@ -23,7 +23,7 @@ class JobrequestsController < ApplicationController
# Update state of request
jr.state = 0
jr.result = 'Job approved'
jr.result = 'Approved'
jr.timestampcompleted = DateTime.now
jr.save
......@@ -35,8 +35,17 @@ class JobrequestsController < ApplicationController
def disapprove
if params[:disapprove_reason]
# Update request
jr = Jobrequest.find(params[:id])
jr.state = 1
jr.result = "Disapproved: #{params[:disapprove_reason][:reason]}"
jr.timestampcompleted = DateTime.now
jr.save
# Send email explaining disapproval
raise "SHOOP DA WHOOP"
JobwaitingMailer.jobdisapproved(jr, params[:disapprove_reason][:reason]).deliver
redirect_to jr
end
end
......
......@@ -5,4 +5,10 @@ class JobwaitingMailer < ActionMailer::Base
@jobrequest = jobrequest
mail :to => @jobrequest.email, :subject => "New pending job for #{@jobrequest.user}"
end
def jobdisapproved(jobrequest, reason)
@reason = reason
job = Command.find(jobrequest.command_id)
mail :to => jobrequest.email, :subject => "#{job.name} disapproved"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment