add: init data button

This commit is contained in:
yystopf 2021-09-22 09:53:43 +08:00
parent 0581c59a84
commit 53212975f1
3 changed files with 18 additions and 1 deletions

View File

@ -19,6 +19,16 @@ class Admins::MessageTemplatesController < Admins::BaseController
end
end
def init_data
if MessageTemplate.build_init_data
redirect_to admins_message_templates_path
flash[:success] = '消息模版初始化成功'
else
redirect_to admins_message_templates_path
flash[:danger] = '消息模版初始化失败'
end
end
private
def message_template_params
params.require(:message_template).permit!

View File

@ -2,6 +2,9 @@
<% add_admin_breadcrumb('消息模版') %>
<% end %>
<div id="admins-message-templates-content">
<div class="box search-form-container project-list-form">
<%= link_to "初始化数据", init_data_admins_message_templates_path, class: "btn btn-primary pull-right", "data-disabled-with":"...初始化数据" %>
</div>
<div class="box admin-list-container message-templates-list-container">
<%= render partial: 'admins/message_templates/list', locals: { message_templates: @message_templates } %>
</div>

View File

@ -668,7 +668,11 @@ Rails.application.routes.draw do
resources :project_licenses
resources :project_ignores
resources :reversed_keywords
resources :message_templates, only: [:index, :edit, :update]
resources :message_templates, only: [:index, :edit, :update] do
collection do
get :init_data
end
end
resources :major_informations, only: [:index]
resources :ec_templates, only: [:index, :destroy] do
collection do