Fix #4178: add ability to mass undo tag edits.
Adds checkboxes to the /post_versions index allowing you to select and undo multiple versions at once.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
class PostArchive < ApplicationRecord
|
||||
class RevertError < Exception ; end
|
||||
extend Memoist
|
||||
|
||||
belongs_to :post
|
||||
@@ -218,7 +219,9 @@ class PostArchive < ApplicationRecord
|
||||
source.gsub(/^http:\/\//, "").sub(/\/.+/, "")
|
||||
end
|
||||
|
||||
def undo
|
||||
def undo!
|
||||
raise RevertError unless post.visible?
|
||||
|
||||
added = changes[:added_tags] - changes[:obsolete_added_tags]
|
||||
removed = changes[:removed_tags] - changes[:obsolete_removed_tags]
|
||||
|
||||
@@ -239,11 +242,16 @@ class PostArchive < ApplicationRecord
|
||||
post.tag_string = "#{post.tag_string} #{tag}".strip
|
||||
end
|
||||
end
|
||||
|
||||
post.save!
|
||||
end
|
||||
|
||||
def undo!
|
||||
undo
|
||||
post.save!
|
||||
def can_undo?(user)
|
||||
version > 1 && post&.visible? && user.is_member?
|
||||
end
|
||||
|
||||
def can_revert_to?(user)
|
||||
post&.visible? && user.is_member?
|
||||
end
|
||||
|
||||
def updater_name
|
||||
|
||||
Reference in New Issue
Block a user