diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index 9f21bfb..3fb3c4e 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -30,11 +30,11 @@ class Admin::JournalPapersController < OrbitMemberController def new @journal_paper = JournalPaper.new - @members_data = JournalPaper.member_data rescue nil + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil end def edit - @members_data = JournalPaper.member_data rescue nil + @member = @journal_paper.member_profile end def create @@ -51,8 +51,6 @@ class Admin::JournalPapersController < OrbitMemberController end def update - @journal_paper_authors = @journal_paper.journal_paper_authors - respond_to do |format| if @journal_paper.update_attributes(journal_paper_attributes) format.html { redirect_to params['referer_url'] } diff --git a/app/controllers/journal_papers_controller.rb b/app/controllers/journal_papers_controller.rb index 0b419e7..cd2477c 100644 --- a/app/controllers/journal_papers_controller.rb +++ b/app/controllers/journal_papers_controller.rb @@ -29,6 +29,7 @@ class JournalPapersController < ApplicationController "journal_title", "level_type", "paper_type", + "author_name", "authors", "author_type", "year", @@ -41,6 +42,7 @@ class JournalPapersController < ApplicationController "total_pages", "isbn", "url", + "associated_project", "note", "file" ] diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index 39426e4..e321ecb 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -9,6 +9,9 @@ class JournalPaper field :paper_title, as: :slug_title, type: String, localize: true field :journal_title, type: String, localize: true + field :authors, type: String, localize: true + field :associated_project , type: String, localize: true + field :year, type: String field :language, type: String field :isbn, type: String @@ -22,6 +25,7 @@ class JournalPaper field :publication_date, type: DateTime field :url, type: String field :note, type: String + field :number_of_authors field :rss2_id paginates_per 10 @@ -34,12 +38,12 @@ class JournalPaper has_many :journal_paper_files, autosave: true, dependent: :destroy accepts_nested_attributes_for :journal_paper_files - has_and_belongs_to_many :journal_paper_authors, dependent: :destroy - accepts_nested_attributes_for :journal_paper_authors + # has_and_belongs_to_many :journal_paper_authors, dependent: :destroy + # accepts_nested_attributes_for :journal_paper_authors has_and_belongs_to_many :journal_paper_author_types - after_save :save_journal_paper_files, :save_journal_paper_authors + # after_save :save_journal_paper_files, :save_journal_paper_authors before_validation :add_http # validates :paper_title, presence: true @@ -48,7 +52,7 @@ class JournalPaper title = [] title << self.member_profile.name if self.member_profile_id.present? - title << (!self.journal_paper_authors.blank? ? "#{self.journal_paper_authors.collect{|j| j.name}.join(', ')}" : nil) + title << (!self.authors.blank? ? self.authors : nil) if !self.publication_date.nil? pd = self.publication_date.strftime("%Y-%m-%d").split('-') title << pd[0] @@ -62,41 +66,34 @@ class JournalPaper title.join(', ').gsub(', ,',',') end - def authors - authors = [] - authors << self.member_profile.name if self.member_profile_id.present? - authors << self.journal_paper_authors.collect{|j| j.name}.join(', ') unless self.journal_paper_authors.blank? - authors.join(', ') - end + # def self.member_data + # members = MemberProfile.all + # member_data = [] + # members.each do |m| + # if (m.first_name || m.last_name) + # member_data << {"memberId" => m.id.to_s, "memberName" => m.name} + # else + # member_data << {"memberId" => m.id.to_s, "memberName" => "No Name"} + # end + # end + # member_data.to_json + # end - def self.member_data - members = MemberProfile.all - member_data = [] - members.each do |m| - if (m.first_name || m.last_name) - member_data << {"memberId" => m.id.to_s, "memberName" => m.name} - else - member_data << {"memberId" => m.id.to_s, "memberName" => "No Name"} - end - end - member_data.to_json - end + # def save_journal_paper_files + # self.journal_paper_files.each do |t| + # if t.should_destroy + # t.destroy + # end + # end + # end - def save_journal_paper_files - self.journal_paper_files.each do |t| - if t.should_destroy - t.destroy - end - end - end - - def save_journal_paper_authors - self.journal_paper_authors.each do |t| - if t.should_destroy - t.destroy - end - end - end + # def save_journal_paper_authors + # self.journal_paper_authors.each do |t| + # if t.should_destroy + # t.destroy + # end + # end + # end def get_plugin_data(fields_to_show) plugin_datas = [] @@ -116,6 +113,14 @@ class JournalPaper value = self.journal_paper_author_types.collect{|type| type.title}.join(',') rescue "" when "paper_type" value = self.journal_paper_type.title rescue "" + when "author_name" + value = [] + ([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale| + if self.member_profile.first_name_translations[locale] || self.member_profile.last_name_translations[locale] + value << "#{self.member_profile.first_name_translations[locale]} #{self.member_profile.last_name_translations[locale]}" + end + end + value = value.join(" / ") when "publication_date" value = self.publication_date.to_date.strftime("%Y-%m-%d") rescue "" when "language" diff --git a/app/views/admin/journal_papers/_form.html.erb b/app/views/admin/journal_papers/_form.html.erb index 793efd0..46f5fd0 100644 --- a/app/views/admin/journal_papers/_form.html.erb +++ b/app/views/admin/journal_papers/_form.html.erb @@ -20,8 +20,7 @@
- <%= t(:add) %> -
-