From 0b60e4886eaab2fc9faf73b1ec238f522e91b9d2 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Thu, 3 Jul 2014 22:39:01 +0800 Subject: [PATCH] fixed journal paper author type in form --- app/helpers/admin/journal_papers_helper.rb | 6 +++--- app/models/journal_paper.rb | 2 ++ app/models/journal_paper_author_type.rb | 1 + app/views/admin/journal_papers/_form.html.erb | 3 +-- app/views/plugin/journal_paper/_profile.html.erb | 1 - config/routes.rb | 4 +--- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index 5c40ff1..c072f7b 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -1,9 +1,9 @@ module Admin::JournalPapersHelper - def page_for_journal_paper(journal_paper) + def page_for_journal_paper(journal_paper_object) journal_paper_page = nil - pages = Page.where(:module=>"member") + pages = Page.where(:module=>"journal_paper") journal_paper_page = pages.first if journal_paper_page.nil? - request.protocol+(request.host_with_port+journal_paper_page.url+'/'+journal_paper.to_param+"?method=personal_plugin&plugin_name=JournalPaper").gsub('//','/') rescue "/" + request.protocol+(request.host_with_port+journal_paper_page.url+'/'+journal_paper_object.to_param).gsub('//','/') rescue "/" end end diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index 86c94ba..f870b74 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -36,6 +36,8 @@ class JournalPaper has_and_belongs_to_many :journal_paper_authors 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 before_validation :add_http diff --git a/app/models/journal_paper_author_type.rb b/app/models/journal_paper_author_type.rb index 71ad4d5..97672dc 100644 --- a/app/models/journal_paper_author_type.rb +++ b/app/models/journal_paper_author_type.rb @@ -7,5 +7,6 @@ class JournalPaperAuthorType field :key, type: String field :title, type: String, localize: true + has_and_belongs_to_many :journal_papers has_and_belongs_to_many :journal_paper_authors end diff --git a/app/views/admin/journal_papers/_form.html.erb b/app/views/admin/journal_papers/_form.html.erb index 28c2824..fee5018 100644 --- a/app/views/admin/journal_papers/_form.html.erb +++ b/app/views/admin/journal_papers/_form.html.erb @@ -100,9 +100,8 @@
<% @author_types.each do |author_type| %> <%= content_tag :label,:class => "checkbox inline" do -%> - <%= check_box_tag 'journal_paper[journal_paper_author_type_ids][]', author_type.id, @journal_paper.journal_paper_author_ids.include?(author_type.id)%> + <%= check_box_tag 'journal_paper[journal_paper_author_type_ids][]', author_type.id, @journal_paper.journal_paper_author_type_ids.include?(author_type.id)%> <%= author_type.title %> - <%= hidden_field_tag 'journal_paper[journal_paper_author_type_ids][]', '' %> <% end %> <% end %>
diff --git a/app/views/plugin/journal_paper/_profile.html.erb b/app/views/plugin/journal_paper/_profile.html.erb index 0ccd75e..594f68b 100644 --- a/app/views/plugin/journal_paper/_profile.html.erb +++ b/app/views/plugin/journal_paper/_profile.html.erb @@ -66,7 +66,6 @@ <%= writing_journal.year %> <%= link_to writing_journal.create_link, page_for_journal_paper(writing_journal), target: "blank"%> -