1
0
Fork 0
discourse-custom-wizard-unl.../extensions/discourse_tagging.rb
Faizaan Gagan f0580d2bba
FEATURE: allow tags from tag field to be confined to a tag group (#175)
* FEATURE: allow tag field to be confined to a tag group

* fixed linting

* bump minor version

* moved monkeypatch to a separate module

* use snake case for variable names

* added specs
2022-02-07 11:10:52 +05:30

17 Zeilen
475 B
Ruby

# frozen_string_literal: true
module CustomWizardDiscourseTagging
def filter_allowed_tags(guardian, opts = {})
if tag_groups = RequestStore.store[:tag_groups]
tag_group_array = tag_groups.split(",")
filtered_tags = TagGroup.includes(:tags).where(name: tag_group_array).map do |tag_group|
tag_group.tags.pluck(:name)
end.flatten
opts[:only_tag_names] ||= []
opts[:only_tag_names].push(*filtered_tags)
end
super
end
end