Commit f5da59a1 authored by Cool Fire's avatar Cool Fire

Fixes for requests

parent 934741e3
...@@ -23,7 +23,7 @@ class JobrequestsController < ApplicationController ...@@ -23,7 +23,7 @@ class JobrequestsController < ApplicationController
# Update state of request # Update state of request
jr.state = 0 jr.state = 0
jr.result = 'Job approved' jr.result = 'Approved'
jr.timestampcompleted = DateTime.now jr.timestampcompleted = DateTime.now
jr.save jr.save
...@@ -35,8 +35,17 @@ class JobrequestsController < ApplicationController ...@@ -35,8 +35,17 @@ class JobrequestsController < ApplicationController
def disapprove def disapprove
if params[:disapprove_reason] 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 # Send email explaining disapproval
raise "SHOOP DA WHOOP" JobwaitingMailer.jobdisapproved(jr, params[:disapprove_reason][:reason]).deliver
redirect_to jr
end end
end end
......
...@@ -5,4 +5,10 @@ class JobwaitingMailer < ActionMailer::Base ...@@ -5,4 +5,10 @@ class JobwaitingMailer < ActionMailer::Base
@jobrequest = jobrequest @jobrequest = jobrequest
mail :to => @jobrequest.email, :subject => "New pending job for #{@jobrequest.user}" mail :to => @jobrequest.email, :subject => "New pending job for #{@jobrequest.user}"
end end
def jobdisapproved(jobrequest, reason)
@reason = reason
job = Command.find(jobrequest.command_id)
mail :to => jobrequest.email, :subject => "#{job.name} disapproved"
end
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