mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 09:22:42 +08:00
FEATURE: categories can require topics have a tag from a tag group
In a category's settings, the Tags tab has two new fields to specify the number of tags that must be added to a topic from a tag group. When creating a new topic, an error will be shown to the user if the requirement isn't met.
This commit is contained in:
@ -147,10 +147,10 @@ class TopicCreator
|
||||
def setup_tags(topic)
|
||||
if @opts[:tags].blank?
|
||||
unless @guardian.is_staff? || !guardian.can_tag?(topic)
|
||||
# Validate minimum required tags for a category
|
||||
category = find_category
|
||||
if category.present? && category.minimum_required_tags > 0
|
||||
topic.errors.add(:base, I18n.t("tags.minimum_required_tags", count: category.minimum_required_tags))
|
||||
|
||||
if !DiscourseTagging.validate_min_required_tags_for_category(@guardian, topic, category) ||
|
||||
!DiscourseTagging.validate_required_tags_from_group(@guardian, topic, category)
|
||||
rollback_from_errors!(topic)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user