diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index 3d5fa8d5e..325e69384 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -54,31 +54,28 @@ class ModAction < ApplicationRecord other: 2000 } + def self.permitted(user) + if user.is_moderator? + all + else + where.not(category: [:ip_ban_create, :ip_ban_delete]) + end + end + def self.search(params) q = super + q = q.permitted(CurrentUser.user) q = q.search_attributes(params, :creator, :category, :description) q = q.text_attribute_matches(:description, params[:description_matches]) q.apply_default_order(params) end - def filtered_description - if (ip_ban_create? || ip_ban_delete?) && !CurrentUser.user.is_moderator? - description.gsub(/(created|deleted) ip ban for .*/, "\\1 ip ban") - else - description - end - end - def category_id self.class.categories[category] end - def serializable_hash(*args) - super(*args).merge("description" => filtered_description) - end - def self.log(desc, cat = :other) create(:description => desc,:category => categories[cat]) end diff --git a/app/views/mod_actions/index.html.erb b/app/views/mod_actions/index.html.erb index 50d5489d0..a3722e7da 100644 --- a/app/views/mod_actions/index.html.erb +++ b/app/views/mod_actions/index.html.erb @@ -20,7 +20,7 @@