diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb
index fc889ef..f4a7f6f 100644
--- a/app/helpers/admin/journal_papers_helper.rb
+++ b/app/helpers/admin/journal_papers_helper.rb
@@ -1,44 +1,33 @@
module Admin::JournalPapersHelper
def get_authors_text(journal)
- (journal.authors.to_s.blank? ? get_member(journal).collect(&:name).join('/') : Nokogiri::HTML(journal.authors.to_s).text rescue "")
+ authors_text = Nokogiri::HTML(journal.authors.to_s).text
+ split_text = authors_text.match(/[、,,\/]/)
+ split_text = split_text.nil? ? '/' : split_text[0]
+ full_authors_names = get_member(journal).collect(&:name)
+ if authors_text.present?
+ authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
+ full_authors_names += authors_names
+ end
+ full_authors_names.join(split_text)
end
def get_authors_show(journal)
- begin
- if journal.authors.to_s.blank?
- get_member_show(journal)
- else
- members = get_member(journal)
- if members.blank?
- journal.authors.to_s
- else
- authors = journal.authors.to_s.split(/,|,/).collect{|v| v.strip}
- authors_tp = authors.clone
- locales = Site.first.enable_locales rescue I18n.available_locales
- members_tp = members.select do |member|
- flag = true
- locales.each do |locale|
- name_tp = I18n.with_locale(locale) do
- member.name.strip
- end
- author_index = authors.index(name_tp)
- if !author_index.nil?
- author = authors[author_index]
- authors_tp[author_index] = "#{author}"
- flag = false
- break
- end
- end
- flag
- end
- (get_a_tag_from_members(members_tp) + authors_tp).join('、')
- end
- end
- rescue => e
- ""
+ authors_text = Nokogiri::HTML(journal.authors.to_s).text
+ split_text = authors_text.match(/[、,,\/]/)
+ split_text = split_text.nil? ? '/' : split_text[0]
+ full_authors_names = []
+ full_authors = get_member(journal).collect{|member|
+ member_name = member.name
+ full_authors_names << member_name
+ "#{member_name}"
+ }
+ if authors_text.present?
+ authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
+ full_authors += authors_names
end
+ full_authors.join(split_text)
end
def get_member(journal)
- Array(MemberProfile.find(Array(journal).collect(&:member_profile_id))) rescue []
+ Array(MemberProfile.where(:id.in=>Array(journal).collect(&:member_profile_id).flatten))
end
def get_a_tag_from_members(members)
members.collect{|member| "#{member.name}"}