fixes #1653
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
<li><%= link_to "Show", artist_path(@artist) %></li>
|
||||
<% if CurrentUser.is_member? %>
|
||||
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
||||
<% end %>
|
||||
<% if CurrentUser.is_builder? %>
|
||||
<li><%= link_to "Edit name", edit_name_artist_path(@artist) %></li>
|
||||
<% end %>
|
||||
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
||||
|
||||
Reference in New Issue
Block a user