diff --git a/app/controllers/admins/user_actions_controller.rb b/app/controllers/admins/user_actions_controller.rb index cca6f6a14..d7d7b669f 100644 --- a/app/controllers/admins/user_actions_controller.rb +++ b/app/controllers/admins/user_actions_controller.rb @@ -2,8 +2,21 @@ class Admins::UserActionsController < Admins::BaseController before_action :require_admin def index - @user_actions = UserAction.order(created_at: :desc) + @user_actions = UserAction.where.not(action_type: ["CompetitionInfoCreate", "CompetitionInfoUpdate", "CompetitionInfoUp", "CompetitionInfoDown", 'MemoPassed']).order(created_at: :desc) + if params[:action_type].present? + @user_actions = @user_actions.where(action_type: params[:action_type]) + end + keyword = params[:keyword].to_s.strip.presence + if keyword + sql = 'login LIKE :keyword OR phone LIKE :keyword OR email LIKE :keyword' + @user_actions = @user_actions.where(sql, keyword: "%#{keyword}%") + end + @user_actions = paginate @user_actions + end + + def index_1 + @user_actions = UserAction.where(action_type: ["CompetitionInfoCreate", "CompetitionInfoUpdate", "CompetitionInfoUp", "CompetitionInfoDown", 'MemoPassed']).order(created_at: :desc) if params[:action_type].present? if params[:action_type].include?("CompetitionInfo") @user_actions = @user_actions.where(action_type: ["CompetitionInfoCreate", "CompetitionInfoUpdate", "CompetitionInfoUp", "CompetitionInfoDown"]) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 61262cce8..47ced4ed7 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -43,6 +43,7 @@ class UserAction < ApplicationRecord when "CompetitionInfoUp" then "上架竞赛" when "CompetitionInfoDown" then "下架竞赛" when "Attachment" then "上传附件" + when "MemoPassed" then "论坛审核" else self.action_type end end @@ -70,6 +71,7 @@ class UserAction < ApplicationRecord else return "上传附件地址:#{attachment.title}" end + when "MemoPassed" then "#{memo&.subject}" else "--" end end @@ -119,6 +121,14 @@ class UserAction < ApplicationRecord competition_info end + def memo + memo = if action_type == "MemoPassed" && data_bank.present? + Memo.find_by(id: self.action_id) + else + nil + end + end + def build_mode(model_name) model = model_name.constantize.new diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb index 9a66e8ce1..e1271e023 100644 --- a/app/views/admins/user_actions/index.html.erb +++ b/app/views/admins/user_actions/index.html.erb @@ -5,7 +5,7 @@