fixes #948
This commit is contained in:
@@ -132,7 +132,7 @@ class AnonymousUser
|
|||||||
|
|
||||||
def decrement!(field)
|
def decrement!(field)
|
||||||
end
|
end
|
||||||
|
|
||||||
def role
|
def role
|
||||||
:anonymous
|
:anonymous
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ class Note < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_version
|
def create_version
|
||||||
CurrentUser.increment!(:note_update_count)
|
CurrentUser.user.increment!(:note_update_count)
|
||||||
|
update_column(:version, version.to_i + 1)
|
||||||
|
|
||||||
versions.create(
|
versions.create(
|
||||||
:updater_id => updater_id,
|
:updater_id => updater_id,
|
||||||
@@ -134,7 +135,8 @@ class Note < ActiveRecord::Base
|
|||||||
:width => width,
|
:width => width,
|
||||||
:height => height,
|
:height => height,
|
||||||
:is_active => is_active,
|
:is_active => is_active,
|
||||||
:body => body
|
:body => body,
|
||||||
|
:version => version
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><%= link_to note_version.post_id, post_path(note_version.post_id) %></td>
|
<td><%= link_to note_version.post_id, post_path(note_version.post_id) %></td>
|
||||||
<td><%= link_to "#{note_version.note_id}.#{note_version.id}", note_versions_path(:search => {:note_id => note_version.note_id}) %></td>
|
<td><%= link_to "#{note_version.note_id}.#{note_version.version}", note_versions_path(:search => {:note_id => note_version.note_id}) %></td>
|
||||||
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
||||||
<% if CurrentUser.is_janitor? %>
|
<% if CurrentUser.is_janitor? %>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
7
db/migrate/20130322173859_add_version_to_notes.rb
Normal file
7
db/migrate/20130322173859_add_version_to_notes.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class AddVersionToNotes < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
execute("set statement_timeout = 0")
|
||||||
|
add_column :notes, :version, :integer, :null => false, :default => 0
|
||||||
|
add_column :note_versions, :version, :integer, :null => false, :default => 0
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1938,7 +1938,8 @@ CREATE TABLE note_versions (
|
|||||||
is_active boolean DEFAULT true NOT NULL,
|
is_active boolean DEFAULT true NOT NULL,
|
||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone NOT NULL
|
updated_at timestamp without time zone NOT NULL,
|
||||||
|
version integer DEFAULT 0 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -1977,7 +1978,8 @@ CREATE TABLE notes (
|
|||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
body_index tsvector NOT NULL,
|
body_index tsvector NOT NULL,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone NOT NULL
|
updated_at timestamp without time zone NOT NULL,
|
||||||
|
version integer DEFAULT 0 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -6269,4 +6271,6 @@ INSERT INTO schema_migrations (version) VALUES ('20130321144736');
|
|||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20130322162059');
|
INSERT INTO schema_migrations (version) VALUES ('20130322162059');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20130322173202');
|
INSERT INTO schema_migrations (version) VALUES ('20130322173202');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20130322173859');
|
||||||
@@ -5,3 +5,13 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config',
|
|||||||
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||||
|
|
||||||
ActiveRecord::Base.connection.execute("update wiki_pages set updater_id = (select _.updater_id from wiki_page_versions _ where _.wiki_page_id = wiki_pages.id order by _.updated_at desc limit 1)")
|
ActiveRecord::Base.connection.execute("update wiki_pages set updater_id = (select _.updater_id from wiki_page_versions _ where _.wiki_page_id = wiki_pages.id order by _.updated_at desc limit 1)")
|
||||||
|
|
||||||
|
Note.find_each do |note|
|
||||||
|
i = 0
|
||||||
|
versions = note.versions
|
||||||
|
versions.each do |version|
|
||||||
|
i += 1
|
||||||
|
version.update_column(:version, i)
|
||||||
|
end
|
||||||
|
note.update_column(:version, i)
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user