email_templates_controller.rb
1.63 KB
1
2
3
4
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class EmailTemplatesController < ApplicationController
def index
@email_templates = owner.email_templates
end
def show
@email_template = owner.email_templates.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @email_template }
end
end
def show_parsed
@email_template = owner.email_templates.find(params[:id])
template_params = {:profile => owner, :environment => environment}
render json: {:parsed_body => @email_template.parsed_body(template_params), :parsed_subject => @email_template.parsed_subject(template_params)}
end
def new
@email_template = owner.email_templates.build(:owner => owner)
end
def edit
@email_template = owner.email_templates.find(params[:id])
end
def create
@email_template = owner.email_templates.build(params[:email_template])
@email_template.owner = owner
if @email_template.save
session[:notice] = _('Email template was successfully created.')
redirect_to url_for(:action => :index)
else
render action: "new"
end
end
def update
@email_template = owner.email_templates.find(params[:id])
if @email_template.update_attributes(params[:email_template])
session[:notice] = _('Email template was successfully updated.')
redirect_to url_for(:action => :index)
else
render action: "edit"
end
end
def destroy
@email_template = owner.email_templates.find(params[:id])
@email_template.destroy
respond_to do |format|
format.html { redirect_to url_for(:action => :index)}
format.json { head :no_content }
end
end
end