##// END OF EJS Templates
Optimistic locking added for wiki edits....
Jean-Philippe Lang -
r542:f12315075fc5
parent child
Show More
@@ -60,14 +60,18 class WikiController < ApplicationController
60 redirect_to :action => 'index', :id => @project, :page => @page.title
60 redirect_to :action => 'index', :id => @project, :page => @page.title
61 return
61 return
62 end
62 end
63 @content.text = params[:content][:text]
63 #@content.text = params[:content][:text]
64 @content.comments = params[:content][:comments]
64 #@content.comments = params[:content][:comments]
65 @content.attributes = params[:content]
65 @content.author = logged_in_user
66 @content.author = logged_in_user
66 # if page is new @page.save will also save content, but not if page isn't a new record
67 # if page is new @page.save will also save content, but not if page isn't a new record
67 if (@page.new_record? ? @page.save : @content.save)
68 if (@page.new_record? ? @page.save : @content.save)
68 redirect_to :action => 'index', :id => @project, :page => @page.title
69 redirect_to :action => 'index', :id => @project, :page => @page.title
69 end
70 end
70 end
71 end
72 rescue ActiveRecord::StaleObjectError
73 # Optimistic locking exception
74 flash[:notice] = l(:notice_locking_conflict)
71 end
75 end
72
76
73 # show page history
77 # show page history
@@ -18,6 +18,7
18 require 'zlib'
18 require 'zlib'
19
19
20 class WikiContent < ActiveRecord::Base
20 class WikiContent < ActiveRecord::Base
21 set_locking_column :version
21 belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
22 belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
22 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
23 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
23 validates_presence_of :text
24 validates_presence_of :text
@@ -5,6 +5,7
5 <h2><%= @page.pretty_title %></h2>
5 <h2><%= @page.pretty_title %></h2>
6
6
7 <% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %>
7 <% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %>
8 <%= f.hidden_field :version %>
8 <%= error_messages_for 'content' %>
9 <%= error_messages_for 'content' %>
9 <div class="contextual">
10 <div class="contextual">
10 <%= l(:setting_text_formatting) %>:
11 <%= l(:setting_text_formatting) %>:
General Comments 0
You need to be logged in to leave comments. Login now