Browse Source

add: init data button

tags/v3.2.0
yystopf 4 years ago
parent
commit
53212975f1
3 changed files with 18 additions and 1 deletions
  1. +10
    -0
      app/controllers/admins/message_templates_controller.rb
  2. +3
    -0
      app/views/admins/message_templates/index.html.erb
  3. +5
    -1
      config/routes.rb

+ 10
- 0
app/controllers/admins/message_templates_controller.rb 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!


+ 3
- 0
app/views/admins/message_templates/index.html.erb 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>


+ 5
- 1
config/routes.rb 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


Loading…
Cancel
Save