diff --git a/app/logical/reports/janitor_trials.rb b/app/logical/reports/janitor_trials.rb index 26c69e1e7..445a32097 100644 --- a/app/logical/reports/janitor_trials.rb +++ b/app/logical/reports/janitor_trials.rb @@ -39,7 +39,7 @@ module Reports end def janitors - User.where("level >= ?", User::Levels::JANITOR).to_a.map {|x| Janitor.new(x)} + User.where("bit_prefs & ? > 0", User.flag_value_for("can_approve_posts")).to_a.map {|x| Janitor.new(x)} end end end diff --git a/lib/danbooru/has_bit_flags.rb b/lib/danbooru/has_bit_flags.rb index 7e66d5eb5..66ec54008 100644 --- a/lib/danbooru/has_bit_flags.rb +++ b/lib/danbooru/has_bit_flags.rb @@ -11,6 +11,12 @@ module Danbooru attributes.each.with_index do |attribute, i| bit_flag = 1 << i + define_singleton_method("flag_value_for") do |key| + index = attributes.index(key) + raise IndexError if index.nil? + 1 << index + end + define_method(attribute) do send(field) & bit_flag > 0 end