mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Allow multiple required tag groups for a category (#16381)
Previously we only supported a single 'required tag group' for a category. This commit allows admins to specify multiple required tag groups, each with their own minimum tag count. A new category_required_tag_groups database table replaces the existing columns on the categories table. Data is automatically migrated.
This commit is contained in:
@ -312,7 +312,7 @@ class CategoriesController < ApplicationController
|
||||
if SiteSetting.tagging_enabled
|
||||
params[:allowed_tags] = params[:allowed_tags].presence || [] if params[:allowed_tags]
|
||||
params[:allowed_tag_groups] = params[:allowed_tag_groups].presence || [] if params[:allowed_tag_groups]
|
||||
params[:required_tag_group_name] = params[:required_tag_group_name].presence || '' if params[:required_tag_group_name]
|
||||
params[:required_tag_groups] = params[:required_tag_groups].presence || [] if params[:required_tag_groups]
|
||||
end
|
||||
|
||||
if SiteSetting.enable_category_group_moderation?
|
||||
@ -351,8 +351,6 @@ class CategoriesController < ApplicationController
|
||||
:navigate_to_first_post_after_read,
|
||||
:search_priority,
|
||||
:allow_global_tags,
|
||||
:required_tag_group_name,
|
||||
:min_tags_from_required_group,
|
||||
:read_only_banner,
|
||||
:default_list_filter,
|
||||
:reviewable_by_group_id,
|
||||
@ -360,8 +358,13 @@ class CategoriesController < ApplicationController
|
||||
permissions: [*p.try(:keys)],
|
||||
allowed_tags: [],
|
||||
allowed_tag_groups: [],
|
||||
required_tag_groups: [:name, :min_count]
|
||||
)
|
||||
|
||||
if result[:required_tag_groups] && !result[:required_tag_groups].is_a?(Array)
|
||||
raise Discourse::InvalidParameters.new(:required_tag_groups)
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user