FEATURE: allow changing post owners without creating post revision

This commit is contained in:
Arpit Jalan
2016-08-19 22:43:22 +05:30
parent 6356c0555c
commit a590f35982
3 changed files with 10 additions and 4 deletions

View File

@ -101,6 +101,7 @@ class PostRevisor
# - bypass_rate_limiter:
# - bypass_bump: do not bump the topic, even if last post
# - skip_validations: ask ActiveRecord to skip validations
# - skip_revision: do not create a new PostRevision record
def revise!(editor, fields, opts={})
@editor = editor
@fields = fields.with_indifferent_access
@ -134,6 +135,9 @@ class PostRevisor
@validate_topic = @opts[:validate_topic] if @opts.has_key?(:validate_topic)
@validate_topic = !@opts[:validate_topic] if @opts.has_key?(:skip_validations)
@skip_revision = false
@skip_revision = @opts[:skip_revision] if @opts.has_key?(:skip_revision)
Post.transaction do
revise_post
@ -191,6 +195,7 @@ class PostRevisor
end
def should_create_new_version?
return false if @skip_revision
edited_by_another_user? || !ninja_edit? || owner_changed? || force_new_version?
end
@ -324,6 +329,7 @@ class PostRevisor
end
def create_or_update_revision
return if @skip_revision
# don't create an empty revision if something failed
return unless successfully_saved_post_and_topic
@version_changed ? create_revision : update_revision