Wiki API: PUT (solved)

Added by Cyber Tech almost 4 years ago

I've been working a lot with populating the wiki using the api (MediaWiki conversion), and I can't seem to find the right place to add code for what I'd like to do.

I'm looking to set the following data:
  1. created_on during WikiPage.new
  2. updated_on during WikiPage.save

I tried following the data thru wiki_controller.rb (::update, but while I'm not new to ruby, I AM new to Rails, and I'm having trouble figuring out which parts are RedMine vs Rails.

Anyone have any tips on how these could be assigned from the API? Obviously, I'll be restricting to admin access.

-- CyberTech

Replies (1)

RE: Wiki API: PUT - Added by Cyber Tech almost 4 years ago

For anyone else with the same issue, the following allows the wiki API to accept updated_on as a param.

===================================================================
--- wiki_controller.rb  (revision 12484)
+++ wiki_controller.rb  (working copy)
@@ -135,7 +135,7 @@
     @content = @page.content || WikiContent.new(:page => @page)
     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, :updated_on)
     end
     content_params ||= {}

@@ -150,6 +150,7 @@
       @content.text = @text
     end
     @content.author = User.current
+    @content.updated_on = DateTime.parse(content_params[:updated_on].to_s) if content_params[:updated_on]

     if @page.save_with_content(@content)
       attachments = Attachment.attach_files(@page, params[:attachments])

(1-1/1)