mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Default Composer Category Site Setting (#18967)
* FEATURE: Default Composer Category Site Setting - Create the default_composer_category site setting - Replace general_category_id logic for auto selecting the composer category - Prevent Uncategorized from being selected if not allowed - Add default_composer_category option to seeded categories - Create a migration to populate the default_composer_category site setting if there is a general_category_id populated - Added some tests * Add missing translation for the new site setting * fix some js tests * Just check that the header value is null
This commit is contained in:
19
lib/validators/default_composer_category_validator.rb
Normal file
19
lib/validators/default_composer_category_validator.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DefaultComposerCategoryValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
def valid_value?(val)
|
||||
category_id = val.to_i
|
||||
unless SiteSetting.allow_uncategorized_topics
|
||||
return false if category_id == SiteSetting.uncategorized_category_id
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def error_message
|
||||
I18n.t('site_settings.errors.invalid_uncategorized_category_setting')
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user