Prevent reverting to foreign versions (fixes #2711).

This commit is contained in:
evazion
2016-10-10 10:24:49 +00:00
parent 80895ef46e
commit c46b31aa9c
12 changed files with 44 additions and 8 deletions

View File

@@ -1,4 +1,6 @@
class ArtistCommentary < ActiveRecord::Base
class RevertError < Exception ; end
attr_accessor :remove_commentary_tag, :remove_commentary_request_tag, :remove_commentary_check_tag
attr_accessor :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag
attr_accessible :post_id, :original_description, :original_title, :translated_description, :translated_title, :remove_commentary_tag, :remove_commentary_request_tag, :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag, :remove_commentary_check_tag
@@ -76,6 +78,10 @@ class ArtistCommentary < ActiveRecord::Base
end
def revert_to(version)
if post_id != version.post_id
raise RevertError.new("You cannot revert to a previous artist commentary of another post.")
end
self.original_description = version.original_description
self.original_title = version.original_title
self.translated_description = version.translated_description