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:
Krzysztof Kotlarek
2023-05-23 09:53:32 +10:00
committed by GitHub
parent 984a616204
commit 7ead8de232
7 changed files with 148 additions and 14 deletions

View File

@ -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)