2017-01-24 14:36:43 +01:00
|
|
|
class Admin::MailTemplatesController < AdminController
|
2016-08-31 16:07:11 +02:00
|
|
|
before_action :retrieve_procedure
|
|
|
|
|
|
|
|
def index
|
2017-03-05 11:05:28 +01:00
|
|
|
@mails = mails
|
2017-01-24 10:19:42 +01:00
|
|
|
end
|
2016-08-31 16:07:11 +02:00
|
|
|
|
2017-01-24 10:19:42 +01:00
|
|
|
def edit
|
2017-03-05 11:05:28 +01:00
|
|
|
@mail_template = find_the_right_mail params[:id]
|
2016-08-31 16:07:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2017-03-05 11:05:28 +01:00
|
|
|
mail_template = find_the_right_mail params[:id]
|
2017-01-24 14:36:43 +01:00
|
|
|
mail_template.update_attributes(update_params)
|
|
|
|
redirect_to admin_procedure_mail_templates_path
|
2016-08-31 16:07:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-03-05 11:05:28 +01:00
|
|
|
def mails
|
|
|
|
[@procedure.initiated_mail]
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_the_right_mail type
|
|
|
|
mails.find { |m| m.class.slug == type }
|
|
|
|
end
|
|
|
|
|
2016-08-31 16:07:11 +02:00
|
|
|
def update_params
|
2017-03-05 11:05:28 +01:00
|
|
|
{
|
|
|
|
procedure_id: params[:procedure_id],
|
|
|
|
object: params[:mail_template][:object],
|
|
|
|
body: params[:mail_template][:body],
|
|
|
|
}
|
2016-08-31 16:07:11 +02:00
|
|
|
end
|
2017-01-24 10:19:42 +01:00
|
|
|
end
|