mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 10:49:39 +02:00
Added initial mail template editor #2369
This commit is contained in:
parent
5ba39fb406
commit
032cff3cf3
16 changed files with 298 additions and 1 deletions
61
app/controllers/admin/mail_templates_controller.rb
Normal file
61
app/controllers/admin/mail_templates_controller.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
class Admin::MailTemplatesController < AdminController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@q = MailTemplate.search(params[:q])
|
||||
@mail_templates = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@mail_tempalte = MailTemplate.new
|
||||
end
|
||||
|
||||
def show
|
||||
@mail_template = MailTemplate.find(params[:id])
|
||||
@subject = Liquid::Template.parse(@mail_template.subject).render.html_safe
|
||||
@html_body = Liquid::Template.parse(@mail_template.body).render.html_safe
|
||||
@text_body = Liquid::Template.parse(@mail_template.text_body).render.html_safe
|
||||
end
|
||||
|
||||
def edit
|
||||
@mail_template = MailTemplate.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@mail_template = MailTemplate.new(mail_template_params)
|
||||
|
||||
if @mail_template.save
|
||||
redirect_to [:admin, @mail_template]
|
||||
else
|
||||
flash.now[:alert] = I18n.t(:failure)
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@mail_template = MailTemplate.find(params[:id])
|
||||
|
||||
if @mail_template.update_attributes(mail_template_params)
|
||||
redirect_to [:admin, @mail_template]
|
||||
else
|
||||
flash.now[:alert] = I18n.t(:failure)
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@mail_template = MailTemplate.find(params[:id])
|
||||
if @mail_template.destroy
|
||||
redirect_to admin_mail_templates_path, notise: t(:deleted)
|
||||
else
|
||||
flash.now[:alert] = I18n.t(:failure)
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mail_template_params
|
||||
params.require(:mail_template).permit(:name, :subject, :from, :bcc, :cc, :body, :text_body)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue