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
This commit is contained in:
Jean-Philippe Lang
2011-12-17 11:44:04 +00:00
parent c8066879db
commit dcce70095b
5 changed files with 55 additions and 16 deletions
+9 -1
View File
@@ -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])