Ability to edit a wiki page's parent on the edit page (#6449).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8787 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
6c27093a8b
commit
001b255b08
4 files changed
+70
-13
No files matched your search
@@ -123,6 +123,7 @@ class WikiController < ApplicationController
|
||||
def update
|
||||
return render_403 unless editable?
|
||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||
@page.safe_attributes = params[:wiki_page]
|
||||
|
||||
@content = @page.content_for_version(params[:version])
|
||||
@content.text = initial_page_content(@page) if @content.text.blank?
|
||||
@@ -132,11 +133,12 @@ class WikiController < ApplicationController
|
||||
if !@page.new_record? && params[:content].present? && @content.text == params[:content][:text]
|
||||
attachments = Attachment.attach_files(@page, params[:attachments])
|
||||
render_attachment_warning_if_needed(@page)
|
||||
# don't save if text wasn't changed
|
||||
# don't save content if text wasn't changed
|
||||
@page.save
|
||||
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@content.comments = params[:content][:comments]
|
||||
@text = params[:content][:text]
|
||||
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
||||
@@ -148,11 +150,8 @@ 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)
|
||||
@page.content = @content
|
||||
if @page.save
|
||||
attachments = Attachment.attach_files(@page, params[:attachments])
|
||||
render_attachment_warning_if_needed(@page)
|
||||
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
|
||||
|
||||
@@ -19,6 +19,8 @@ require 'diff'
|
||||
require 'enumerator'
|
||||
|
||||
class WikiPage < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
belongs_to :wiki
|
||||
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
|
||||
acts_as_attachable :delete_permission => :delete_wiki_pages_attachments
|
||||
@@ -55,6 +57,9 @@ class WikiPage < ActiveRecord::Base
|
||||
# Wiki pages that are protected by default
|
||||
DEFAULT_PROTECTED_PAGES = %w(sidebar)
|
||||
|
||||
safe_attributes 'parent_id',
|
||||
:if => lambda {|page, user| page.new_record? || user.allowed_to?(:rename_wiki_pages, page.project)}
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase)
|
||||
|
||||
@@ -13,8 +13,13 @@
|
||||
<div class="box tabular">
|
||||
<%= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %>
|
||||
|
||||
<% if @page.new_record? && @page.parent %>
|
||||
<p><label><%= check_box_tag 'page[parent_id]', @page.parent.id, true %> <%= l(:field_parent_title) %></label> <%=h @page.parent.pretty_title %></p>
|
||||
<% if @page.safe_attribute_names.include?('parent_id') && @wiki.pages.any? %>
|
||||
<% fields_for @page do |fp| %>
|
||||
<p>
|
||||
<label><%= l(:field_parent_title) %></label>
|
||||
<%= fp.select :parent_id, "<option value=''></option>" + wiki_page_options_for_select(@wiki.pages.all(:include => :parent) - @page.self_and_descendants, @page.parent) %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<p><label><%= l(:field_comments) %></label><%= f.text_field :comments, :size => 120 %></p>
|
||||
|
||||
Reference in new issue
Block a user