From ab52b40c0290aafe20b9bbcb284a68b7c6719592 Mon Sep 17 00:00:00 2001 From: albert Date: Wed, 20 Feb 2013 13:58:37 -0500 Subject: [PATCH] fix artist other names --- app/models/artist.rb | 17 ++++++-- app/views/artists/_form.html.erb | 2 +- app/views/artists/show.html.erb | 74 ++++++++++---------------------- 3 files changed, 37 insertions(+), 56 deletions(-) diff --git a/app/models/artist.rb b/app/models/artist.rb index 41096c6d0..31400ef29 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -12,7 +12,7 @@ class Artist < ActiveRecord::Base has_one :wiki_page, :foreign_key => "title", :primary_key => "name" has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name" accepts_nested_attributes_for :wiki_page - attr_accessible :body, :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active, :as => [:member, :privileged, :platinum, :contributor, :janitor, :moderator, :default, :admin] + attr_accessible :body, :name, :url_string, :other_names, :other_names_comma, :group_name, :wiki_page_attributes, :notes, :is_active, :as => [:member, :privileged, :platinum, :contributor, :janitor, :moderator, :default, :admin] attr_accessible :is_banned, :as => :admin module UrlMethods @@ -64,9 +64,18 @@ class Artist < ActiveRecord::Base def normalize_name self.name = Artist.normalize_name(name) - if other_names - self.other_names = other_names.split(/,/).map {|x| Artist.normalize_name(x)}.join(" ") - end + end + + def other_names_array + other_names.split(/ /) + end + + def other_names_comma + other_names_array.join(", ") + end + + def other_names_comma=(string) + self.other_names = string.split(/,/).map {|x| Artist.normalize_name(x)}.join(" ") end end diff --git a/app/views/artists/_form.html.erb b/app/views/artists/_form.html.erb index 3a03f0df4..caec2f855 100644 --- a/app/views/artists/_form.html.erb +++ b/app/views/artists/_form.html.erb @@ -1,6 +1,6 @@ <%= simple_form_for(@artist) do |f| %> <%= f.input :name %> - <%= f.input :other_names, :hint => "Separate with commas", :as => :text %> + <%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %> <%= f.input :group_name %> <%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %> <%= f.input :is_active %> diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index f94aba743..d32735032 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -9,57 +9,29 @@ <% end %>
- - - - - - - <% if @artist.has_tag_alias? %> - - - - - <% end %> - <% if !@artist.other_names.blank? %> - - - - - <% end %> - <% if !@artist.group_name.blank? %> - - - - - <% end %> - <% if @artist.members.any? %> - - - - - <% end %> - <% @artist.urls.each do |url| %> - - - - - <% end %> - -
Status<%= @artist.status %>
Tag Alias - <%= @artist.tag_alias_name %> -
Other Names - <%= link_to_artists(@artist.other_names.split(/,/)) %> -
Group - <%= link_to_artist(@artist.group_name) %> -
Members - <%= link_to_artists(@artist.members.map(&:name)) %> -
URLs - <%= link_to h(url.to_s), h(url.to_s) %> - <% if CurrentUser.user.is_moderator? %> - (<%= link_to("mass edit", edit_moderator_tag_path(:antecedent => "-#{@artist.name} source:#{ArtistUrl.normalize_for_search(url.to_s)}", :consequent => @artist.name)) %>) - <% end %> -
+