FIX: tag input doesn't show staff-only tags to non-staff

This commit is contained in:
Neil Lalonde 2016-05-26 17:24:03 -04:00
parent af1c994940
commit 3d5716a2c8
2 changed files with 6 additions and 1 deletions

View File

@ -78,7 +78,7 @@ export default Ember.TextField.extend({
url: Discourse.getURL("/tags/filter/search"),
dataType: 'json',
data: function (term) {
return { q: term, limit: self.siteSettings.max_tag_search_results };
return { q: term, limit: self.siteSettings.max_tag_search_results, filterForInput: true };
},
results: function (data) {
if (self.siteSettings.tags_sort_alphabetically) {

View File

@ -112,6 +112,11 @@ class TagsController < ::ApplicationController
query = query.where('tags.name like ?', "%#{term}%")
end
if params[:filterForInput] && !guardian.is_staff?
staff_tag_names = SiteSetting.staff_tags.split("|")
query = query.where('tags.name NOT IN (?)', staff_tag_names) if staff_tag_names.present?
end
tags = query.count.map {|t, c| { id: t, text: t, count: c } }
render json: { results: tags }