diff --git a/app/assets/javascripts/journal_papers.js b/app/assets/javascripts/journal_papers.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/journal_papers.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/journal_papers.css b/app/assets/stylesheets/journal_papers.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/journal_papers.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index d885dff..d5309cc 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -32,7 +32,6 @@ class Admin::JournalPapersController < OrbitMemberController end def edit - @journal_paper = JournalPaper.find(params[:id]) @members_data = JournalPaper.member_data rescue nil end @@ -50,17 +49,16 @@ class Admin::JournalPapersController < OrbitMemberController end def update - @writing_journal = JournalPaper.find(params[:id]) - @journal_paper_authors = @writing_journal.journal_paper_authors + @journal_paper_authors = @journal_paper.journal_paper_authors respond_to do |format| - if @writing_journal.update_attributes(journal_paper_attributes) + if @journal_paper.update_attributes(journal_paper_attributes) format.html { redirect_to admin_journal_papers_path } # format.js { render 'toggle_enable' } format.xml { head :ok } else format.html { render action: "edit" } - format.xml { render :xml => @writing_journal.errors, :status => :unprocessable_entity } + format.xml { render :xml => @journal_paper.errors, :status => :unprocessable_entity } end end end @@ -168,7 +166,15 @@ class Admin::JournalPapersController < OrbitMemberController private def set_journal_paper - @journal_paper = JournalPaper.find(params[:id]) + path = request.path.split('/') + if path.last.include? '-' + uid = path[-1].split("-").last + uid = uid.split("?").first + else + uid = path[-2].split("-").last + uid = uid.split("?").first + end + @journal_paper = JournalPaper.find_by(uid: uid) end def journal_paper_attributes diff --git a/app/helpers/journal_papers_helper.rb b/app/helpers/journal_papers_helper.rb new file mode 100644 index 0000000..68f4404 --- /dev/null +++ b/app/helpers/journal_papers_helper.rb @@ -0,0 +1,2 @@ +module JournalPapersHelper +end diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index 3226317..73e6f33 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -4,8 +4,10 @@ class JournalPaper include Mongoid::Attributes::Dynamic include OrbitModel::Status + include MemberHelper + include Slug - field :paper_title, type: String, localize: true + field :paper_title, as: :slug_title, type: String, localize: true field :journal_title, type: String, localize: true field :year, type: String field :language, type: String @@ -89,6 +91,16 @@ class JournalPaper end end + def values_for_view + attribute_values = self.attributes.select{|k,v| v if k.in?(["year","language","isbn","vol_no","issue_no","form_to_start","form_to_end","total_pages","keywords","abstract","publication_date","url","note"])} + localized_fields = {"paper_title" => self.attributes["paper_title"][I18n.locale], "journal_title" => self.attributes["journal_title"][I18n.locale]} + authors = {"authors" => self.authors} + files = Hash.new + self.journal_paper_files.each do |f| files = {"file_link" => url_to_file(f.journal_file.url, f.title)} end + values = [attribute_values, localized_fields, authors,files] + values.inject(&:merge) + end + protected def add_http diff --git a/app/views/plugin/journal_paper/_profile.html.erb b/app/views/plugin/journal_paper/_profile.html.erb index 085c7e6..af0c146 100644 --- a/app/views/plugin/journal_paper/_profile.html.erb +++ b/app/views/plugin/journal_paper/_profile.html.erb @@ -65,7 +65,7 @@ <% end -%> <%= writing_journal.year %> - <%= link_to writing_journal.create_link, admin_journal_paper_path(writing_journal) %> + <%= link_to writing_journal.create_link %>