mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-20 11:45:57 +08:00
add: message template management
This commit is contained in:
34
app/controllers/admins/message_templates_controller.rb
Normal file
34
app/controllers/admins/message_templates_controller.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class Admins::MessageTemplatesController < Admins::BaseController
|
||||
before_action :get_template, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
message_templates = MessageTemplate.group(:type).count.keys
|
||||
@message_templates = kaminari_array_paginate(message_templates)
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @message_template.update_attributes(message_template_params)
|
||||
redirect_to admins_message_templates_path
|
||||
flash[:success] = '消息模版更新成功'
|
||||
else
|
||||
redirect_to admins_message_templates_path
|
||||
flash[:danger] = @message_template.errors.full_messages.join(",")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def message_template_params
|
||||
params.require(:message_template).permit!
|
||||
end
|
||||
|
||||
def get_template
|
||||
@message_template = MessageTemplate.find_by(id: params[:id])
|
||||
unless @message_template.present?
|
||||
redirect_to admins_message_templates_path
|
||||
flash[:danger] = "消息模版不存在"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user