mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: endpoint to reset community community-section (#21664)
In upcoming PRs, admins will be able to edit the Community section. We need an endpoint which allows resetting it to the default state.
This commit is contained in:

committed by
GitHub

parent
984a616204
commit
7ead8de232
@ -50,6 +50,18 @@ class SidebarSectionsController < ApplicationController
|
||||
render json: failed_json, status: 403
|
||||
end
|
||||
|
||||
def reset
|
||||
sidebar_section = SidebarSection.find_by(id: params[:id])
|
||||
raise Discourse::InvalidParameters if !sidebar_section
|
||||
@guardian.ensure_can_edit!(sidebar_section)
|
||||
|
||||
case sidebar_section.section_type
|
||||
when "community"
|
||||
sidebar_section.reset_community!
|
||||
end
|
||||
render_serialized(sidebar_section.reload, SidebarSectionSerializer)
|
||||
end
|
||||
|
||||
def reorder
|
||||
sidebar_section = SidebarSection.find_by(id: reorder_params["sidebar_section_id"])
|
||||
@guardian.ensure_can_edit!(sidebar_section)
|
||||
|
Reference in New Issue
Block a user