Project

General

Profile

Actions

Patch #14829

closed

Patch for setting parent page via REST API

Added by Michael Medin about 11 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Patch to support setting parent-page for WIKI entries via REST API:

 app/controllers/wiki_controller.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index a1d68ed..898eedc 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -138,12 +138,13 @@ class WikiController < ApplicationController
     @content = @page.content
     content_params = params[:content]
     if content_params.nil? && params[:wiki_page].is_a?(Hash)
-      content_params = params[:wiki_page].slice(:text, :comments, :version)
+      content_params = params[:wiki_page].slice(:text, :comments, :version, :parent_title)
     end
     content_params ||= {}

     @content.comments = content_params[:comments]
     @text = content_params[:text]
+    @parent_title = content_params[:parent_title]
     if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
       @section = params[:section].to_i
       @section_hash = params[:section_hash]
@@ -151,6 +152,7 @@ class WikiController < ApplicationController
     else
       @content.version = content_params[:version] if content_params[:version]
       @content.text = @text
+      @page.parent_title = @parent_title
     end
     @content.author = User.current

Usage:

PUT /projects/foo/wiki/[WIKI ENTRY].json
{
  "wiki_page": {
    "parent_title": "[PARENT_PAGE_TITLE]",
    "text": "[CONTENT]",
    "comment": "[COMMENT]" 
  }
}

// Michael Medin

Actions

Also available in: Atom PDF