#1189: Don't record artist history without change
This commit is contained in:
@@ -54,6 +54,10 @@ class Artist < ActiveRecord::Base
|
|||||||
def url_string
|
def url_string
|
||||||
@url_string || urls.map {|x| x.url}.join("\n")
|
@url_string || urls.map {|x| x.url}.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def url_string_changed?
|
||||||
|
url_string.scan(/\S+/) != urls.map(&:url)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module NameMethods
|
module NameMethods
|
||||||
@@ -89,18 +93,20 @@ class Artist < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
module VersionMethods
|
module VersionMethods
|
||||||
def create_version
|
def create_version(force=false)
|
||||||
ArtistVersion.create(
|
if name_changed? || url_string_changed? || is_active_changed? || is_banned_changed? || other_names_changed? || group_name_changed? || notes_changed? || force
|
||||||
:artist_id => id,
|
ArtistVersion.create(
|
||||||
:name => name,
|
:artist_id => id,
|
||||||
:updater_id => CurrentUser.user.id,
|
:name => name,
|
||||||
:updater_ip_addr => CurrentUser.ip_addr,
|
:updater_id => CurrentUser.user.id,
|
||||||
:url_string => url_string,
|
:updater_ip_addr => CurrentUser.ip_addr,
|
||||||
:is_active => is_active,
|
:url_string => url_string,
|
||||||
:is_banned => is_banned,
|
:is_active => is_active,
|
||||||
:other_names => other_names,
|
:is_banned => is_banned,
|
||||||
:group_name => group_name
|
:other_names => other_names,
|
||||||
)
|
:group_name => group_name
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def revert_to!(version)
|
def revert_to!(version)
|
||||||
@@ -157,15 +163,26 @@ class Artist < ActiveRecord::Base
|
|||||||
else
|
else
|
||||||
wiki_page.body = msg
|
wiki_page.body = msg
|
||||||
end
|
end
|
||||||
wiki_page.save if wiki_page.body_changed?
|
if wiki_page.body_changed?
|
||||||
|
wiki_page.save
|
||||||
|
@notes_changed = true
|
||||||
|
end
|
||||||
elsif old_wiki_page
|
elsif old_wiki_page
|
||||||
old_wiki_page.title = name
|
old_wiki_page.title = name
|
||||||
old_wiki_page.body = msg
|
old_wiki_page.body = msg
|
||||||
old_wiki_page.save if old_wiki_page.body_changed? || old_wiki_page.title_changed?
|
if old_wiki_page.body_changed? || old_wiki_page.title_changed?
|
||||||
|
old_wiki_page.save
|
||||||
|
@notes_changed = true
|
||||||
|
end
|
||||||
elsif msg.present?
|
elsif msg.present?
|
||||||
self.wiki_page = WikiPage.new(:title => name, :body => msg)
|
self.wiki_page = WikiPage.new(:title => name, :body => msg)
|
||||||
|
@notes_changed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notes_changed?
|
||||||
|
!!@notes_changed
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module TagMethods
|
module TagMethods
|
||||||
|
|||||||
Reference in New Issue
Block a user