Merge branch 'master' into 'master'

fix undefined method(book_paper_type)



See merge request !6
This commit is contained in:
wmcheng 2019-11-12 22:57:04 +08:00
commit ea6f6c07c8
1 changed files with 6 additions and 4 deletions

View File

@ -40,7 +40,9 @@ class Book
before_validation :add_http before_validation :add_http
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc", :publication_date => "desc") } scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc", :publication_date => "desc") }
def book_paper_type
self.book_type.title rescue ""
end
def create_link def create_link
title = [] title = []
# title << self.member_profile.name if self.member_profile.present? # title << self.member_profile.name if self.member_profile.present?
@ -152,9 +154,9 @@ class Book
def get_plugin_field_data(field) def get_plugin_field_data(field)
case field case field
when "book_paper_type" when "book_paper_type"
value = self.book_type.title rescue "" value = (self.book_type.title rescue "")
when "author_type" when "author_type"
value = self.book_author_types.collect{|type| type.title}.join(',') rescue "" value = (self.book_author_types.collect{|type| type.title}.join(',') rescue "")
when "author_name" when "author_name"
value = [] value = []
([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale| ([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale|
@ -180,7 +182,7 @@ class Book
when "authors" when "authors"
value = get_authors_show(self) value = get_authors_show(self)
else else
value = self.send(field) rescue "" value = (self.send(field) rescue "")
end end
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value