mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: configurable public sidebar sections (#20303)
Extension of https://github.com/discourse/discourse/pull/20057 Admin can create a public session visible to everyone. An additional checkbox is displayed for staff members.
This commit is contained in:
committed by
GitHub
parent
e3ee81aa3c
commit
b9d037770c
@@ -77,6 +77,13 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
|
||||
has_one :user_option, embed: :object, serializer: CurrentUserOptionSerializer
|
||||
|
||||
def sidebar_sections
|
||||
SidebarSection
|
||||
.where("public OR user_id = ?", object.id)
|
||||
.order("(public IS TRUE) DESC")
|
||||
.map { |section| SidebarSectionSerializer.new(section, root: false) }
|
||||
end
|
||||
|
||||
def groups
|
||||
owned_group_ids = GroupUser.where(user_id: id, owner: true).pluck(:group_id).to_set
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SidebarSectionSerializer < ApplicationSerializer
|
||||
attributes :id, :title, :links, :slug
|
||||
attributes :id, :title, :links, :slug, :public
|
||||
|
||||
def links
|
||||
object.sidebar_section_links.map(&:linkable)
|
||||
|
||||
Reference in New Issue
Block a user