mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FEATURE: allow changing post owners without creating post revision
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user