mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: unable to create new categories
Previous attempt at 70adb940 missed the critical "everyone" group from
staff, leading to a case where staff was no longer able to create categories
This commit is contained in:
@@ -25,4 +25,12 @@ class ApplicationSerializer < ActiveModel::Serializer
|
||||
def cache_fragment(name)
|
||||
ApplicationSerializer.fragment_cache[name] ||= yield
|
||||
end
|
||||
|
||||
def cache_anon_fragment(name, &blk)
|
||||
if scope.anonymous?
|
||||
cache_fragment(name, &blk)
|
||||
else
|
||||
blk.call
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,7 +50,9 @@ class SiteSerializer < ApplicationSerializer
|
||||
end
|
||||
|
||||
def groups
|
||||
object.groups.pluck(:id, :name).map { |id, name| { id: id, name: name } }.as_json
|
||||
cache_anon_fragment("group_names") do
|
||||
object.groups.order(:name).pluck(:id, :name).map { |id, name| { id: id, name: name } }.as_json
|
||||
end
|
||||
end
|
||||
|
||||
def post_action_types
|
||||
|
||||
Reference in New Issue
Block a user