Optimistic locking added for wiki edits.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@545 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c99da15445
commit
f12315075f
|
@ -60,14 +60,18 @@ class WikiController < ApplicationController
|
||||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
redirect_to :action => 'index', :id => @project, :page => @page.title
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@content.text = params[:content][:text]
|
#@content.text = params[:content][:text]
|
||||||
@content.comments = params[:content][:comments]
|
#@content.comments = params[:content][:comments]
|
||||||
|
@content.attributes = params[:content]
|
||||||
@content.author = logged_in_user
|
@content.author = logged_in_user
|
||||||
# if page is new @page.save will also save content, but not if page isn't a new record
|
# 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)
|
if (@page.new_record? ? @page.save : @content.save)
|
||||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
redirect_to :action => 'index', :id => @project, :page => @page.title
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
rescue ActiveRecord::StaleObjectError
|
||||||
|
# Optimistic locking exception
|
||||||
|
flash[:notice] = l(:notice_locking_conflict)
|
||||||
end
|
end
|
||||||
|
|
||||||
# show page history
|
# show page history
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
require 'zlib'
|
require 'zlib'
|
||||||
|
|
||||||
class WikiContent < ActiveRecord::Base
|
class WikiContent < ActiveRecord::Base
|
||||||
|
set_locking_column :version
|
||||||
belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
|
belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
validates_presence_of :text
|
validates_presence_of :text
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<h2><%= @page.pretty_title %></h2>
|
<h2><%= @page.pretty_title %></h2>
|
||||||
|
|
||||||
<% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %>
|
<% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %>
|
||||||
|
<%= f.hidden_field :version %>
|
||||||
<%= error_messages_for 'content' %>
|
<%= error_messages_for 'content' %>
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<%= l(:setting_text_formatting) %>:
|
<%= l(:setting_text_formatting) %>:
|
||||||
|
|
Loading…
Reference in New Issue