diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 17e9e44cd..3ae607380 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -2,6 +2,7 @@ class ArtistsController < ApplicationController respond_to :html, :xml, :json before_filter :member_only, :except => [:index, :show, :banned] before_filter :admin_only, :only => [:ban] + before_filter :builder_only, :only => [:edit_name, :update_name] def new @artist = Artist.new_with_defaults(params) @@ -20,7 +21,7 @@ class ArtistsController < ApplicationController def update_name @artist = Artist.find(params[:id]) - @artist.update_attribute(:name, params[:artist][:name]) + @artist.rename!(params[:artist][:name]) respond_with(@artist) end diff --git a/app/models/artist.rb b/app/models/artist.rb index 2eaf88075..ab1925531 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -78,6 +78,18 @@ class Artist < ActiveRecord::Base def other_names_comma=(string) self.other_names = string.split(/,/).map {|x| Artist.normalize_name(x)}.join(" ") end + + def rename!(new_name) + new_wiki_page = WikiPage.titled(new_name).first + if new_wiki_page + # Merge the old wiki page into the new one + new_wiki_page.update_attributes(:body => new_wiki_page.body + "\n\n" + notes) + else + wiki_page.update_attribute(:title, new_name) + end + reload + update_attribute(:name, new_name) + end end module GroupMethods diff --git a/app/views/artists/_secondary_links.html.erb b/app/views/artists/_secondary_links.html.erb index 5c27f3640..069f9307d 100644 --- a/app/views/artists/_secondary_links.html.erb +++ b/app/views/artists/_secondary_links.html.erb @@ -11,6 +11,8 @@