fixes #1439
This commit is contained in:
@@ -3,7 +3,7 @@ class PostVersionsController < ApplicationController
|
|||||||
rescue_from ActiveRecord::StatementInvalid, :with => :rescue_exception
|
rescue_from ActiveRecord::StatementInvalid, :with => :rescue_exception
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@post_versions = PostVersion.search(params[:search]).order("updated_at desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
@post_versions = PostVersion.search(params[:search]).order("updated_at desc, id desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||||
respond_with(@post_versions) do |format|
|
respond_with(@post_versions) do |format|
|
||||||
format.xml do
|
format.xml do
|
||||||
render :xml => @post_versions.to_xml(:root => "post-versions")
|
render :xml => @post_versions.to_xml(:root => "post-versions")
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Post < ActiveRecord::Base
|
|||||||
has_one :artist_commentary
|
has_one :artist_commentary
|
||||||
has_many :flags, :class_name => "PostFlag", :dependent => :destroy
|
has_many :flags, :class_name => "PostFlag", :dependent => :destroy
|
||||||
has_many :appeals, :class_name => "PostAppeal", :dependent => :destroy
|
has_many :appeals, :class_name => "PostAppeal", :dependent => :destroy
|
||||||
has_many :versions, :class_name => "PostVersion", :dependent => :destroy, :order => "post_versions.id ASC"
|
has_many :versions, :class_name => "PostVersion", :dependent => :destroy, :order => "post_versions.updated_at ASC, post_versions.id ASC"
|
||||||
has_many :votes, :class_name => "PostVote", :dependent => :destroy
|
has_many :votes, :class_name => "PostVote", :dependent => :destroy
|
||||||
has_many :notes, :dependent => :destroy
|
has_many :notes, :dependent => :destroy
|
||||||
has_many :comments, :order => "comments.id", :dependent => :destroy
|
has_many :comments, :order => "comments.id", :dependent => :destroy
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class PostVersion < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sequence_for_post
|
def sequence_for_post
|
||||||
versions = PostVersion.where(:post_id => post_id).order("updated_at desc").all
|
versions = PostVersion.where(:post_id => post_id).order("updated_at desc, id desc").all
|
||||||
diffs = []
|
diffs = []
|
||||||
versions.each_index do |i|
|
versions.each_index do |i|
|
||||||
if i < versions.size - 1
|
if i < versions.size - 1
|
||||||
@@ -130,7 +130,12 @@ class PostVersion < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def previous
|
def previous
|
||||||
PostVersion.where("post_id = ? and updated_at < ?", post_id, updated_at).order("updated_at desc").first
|
if updated_at.to_i == Time.zone.parse("2007-03-14T19:38:12Z").to_i
|
||||||
|
# Old post versions which didn't have updated_at set correctly
|
||||||
|
PostVersion.where("post_id = ? and updated_at = ? and id < ?", post_id, updated_at, id).order("updated_at desc, id desc").first
|
||||||
|
else
|
||||||
|
PostVersion.where("post_id = ? and updated_at < ?", post_id, updated_at).order("updated_at desc, id desc").first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncated_source
|
def truncated_source
|
||||||
|
|||||||
Reference in New Issue
Block a user