disable versioning of posts when creating aliases/implications

This commit is contained in:
r888888888
2013-05-03 16:43:44 -07:00
parent dae4f32f50
commit c0dac889b2
5 changed files with 5 additions and 25 deletions

View File

@@ -3,7 +3,7 @@ class Post < ActiveRecord::Base
class DisapprovalError < Exception ; end
class SearchError < Exception ; end
attr_accessor :old_tag_string, :old_parent_id, :has_constraints
attr_accessor :old_tag_string, :old_parent_id, :has_constraints, :disable_versioning
after_destroy :delete_files
after_destroy :delete_remote_files
after_save :create_version
@@ -868,6 +868,8 @@ class Post < ActiveRecord::Base
module VersionMethods
def create_version
return if disable_versioning
if created_at == updated_at
CurrentUser.increment!(:post_update_count)
versions.create(

View File

@@ -130,6 +130,7 @@ class TagAlias < ActiveRecord::Base
escaped_antecedent_name = Regexp.escape(antecedent_name)
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip
CurrentUser.scoped(creator, creator_ip_addr) do
post.disable_versioning = true
post.update_attributes(
:tag_string => fixed_tags
)

View File

@@ -125,6 +125,7 @@ class TagImplication < ActiveRecord::Base
escaped_antecedent_name = Regexp.escape(antecedent_name)
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{antecedent_name} #{descendant_names} ").strip
CurrentUser.scoped(creator, creator_ip_addr) do
post.disable_versioning = true
post.update_attributes(
:tag_string => fixed_tags
)