summaryrefslogtreecommitdiffstats
path: root/app/controllers/wiki_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-17 11:44:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-17 11:44:04 +0000
commitdcce70095ba1241e209a5a91611480533688b486 (patch)
tree066dd5191997f62902ff8dd96615c3cd8b06bec4 /app/controllers/wiki_controller.rb
parentc8066879dba81f5ff5702f7c877d70e93c748431 (diff)
downloadredmine-dcce70095ba1241e209a5a91611480533688b486.tar.gz
redmine-dcce70095ba1241e209a5a91611480533688b486.zip
Option to set parent automatically for new wiki pages (#3108).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8255 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/wiki_controller.rb')
-rw-r--r--app/controllers/wiki_controller.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 2f4724f38..1aaff4071 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -95,7 +95,12 @@ class WikiController < ApplicationController
# edit an existing page or a new one
def edit
return render_403 unless editable?
- @page.content = WikiContent.new(:page => @page) if @page.new_record?
+ if @page.new_record?
+ @page.content = WikiContent.new(:page => @page)
+ if params[:parent].present?
+ @page.parent = @page.wiki.find_page(params[:parent].to_s)
+ end
+ end
@content = @page.content_for_version(params[:version])
@content.text = initial_page_content(@page) if @content.text.blank?
@@ -143,6 +148,9 @@ class WikiController < ApplicationController
@content.text = @text
end
@content.author = User.current
+ if @page.new_record? && params[:page]
+ @page.parent_id = params[:page][:parent_id]
+ end
# if page is new @page.save will also save content, but not if page isn't a new record
if (@page.new_record? ? @page.save : @content.save)
attachments = Attachment.attach_files(@page, params[:attachments])