Skip to content

Commit

Permalink
Use an Enum class for the Reviewable Priority Site Setting
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed May 24, 2019
1 parent 82f1629 commit fad5d9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
21 changes: 21 additions & 0 deletions app/models/reviewable_priority_setting.rb
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require_dependency 'enum_site_setting'

class ReviewablePrioritySetting < EnumSiteSetting

def self.valid_value?(val)
values.any? { |v| v[:value].to_s == val.to_s }
end

def self.values
Reviewable.priorities.map do |p|
{ name: I18n.t("reviewables.priorities.#{p[0]}"), value: p[0] }
end
end

def self.translate_names?
false
end

end
5 changes: 1 addition & 4 deletions config/site_settings.yml
Expand Up @@ -1410,10 +1410,7 @@ spam:
client: true
type: enum
default: low
choices:
- low
- medium
- high
enum: "ReviewablePrioritySetting"

rate_limits:
unique_posts_mins: 5
Expand Down

0 comments on commit fad5d9c

Please sign in to comment.