forked from saurabh/personal-journal
Update personal_journals_controller.rb
This commit is contained in:
parent
ab5b44aafb
commit
e7880ea2a1
|
@ -21,33 +21,35 @@ class PersonalJournalsController < ApplicationController
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
if params[:selectbox] !=nil
|
if params[:selectbox] !=nil
|
||||||
journal_papers = JournalPaper.where(:is_hidden=>false)#Mongoid::Sessions.default[:journal_papers].find()
|
journal_papers = JournalPaper.where(:is_hidden=>false)#Mongoid::Sessions.default[:journal_papers].find()
|
||||||
journal_papers_count = journal_papers.count
|
journal_papers_count = journal_papers.count
|
||||||
journal_papers_temp = journal_papers.take(journal_papers_count).sort_by{ |tp| [-tp[:year].to_i,-tp[:publication_date].to_i] }
|
journal_papers_temp = journal_papers.take(journal_papers_count).sort_by{ |tp| [-tp[:year].to_i,-tp[:publication_date].to_i] }
|
||||||
case params[:selectbox]
|
case params[:selectbox]
|
||||||
when "paper_title"
|
when "paper_title"
|
||||||
if page.custom_string_field == "table"
|
if page.custom_string_field == "table"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.paper_title.include? params[:keywords]}
|
journal_papers_show = journal_papers_temp.select {|value| value.paper_title.include? params[:keywords]}
|
||||||
else
|
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.create_link.include? params[:keywords]}
|
|
||||||
end
|
|
||||||
when "level_type"
|
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.journal_levels.collect{|x| x.title}.join(', ').to_s.include? params[:keywords]}
|
|
||||||
when "publication_date"
|
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', ').include? params[:keywords]}
|
|
||||||
when "author_type"
|
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.journal_paper_author_types.collect{|jat| jat.title}.join(", ").include? params[:keywords]}
|
|
||||||
else
|
else
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.send(params[:selectbox]).to_s.include? params[:keywords]}
|
journal_papers_show = journal_papers_temp.select {|value| value.create_link.include? params[:keywords]}
|
||||||
end
|
end
|
||||||
if params[:page_no].nil?
|
when "level_type"
|
||||||
page_to_show = 1
|
journal_papers_show = journal_papers_temp.select {|value| value.journal_levels.collect{|x| x.title}.join(', ').to_s.include? params[:keywords]}
|
||||||
else
|
when "publication_date"
|
||||||
page_to_show = params[:page_no].to_i
|
journal_papers_show = journal_papers_temp.select {|value| value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', ').include? params[:keywords]}
|
||||||
end
|
when "author_type"
|
||||||
journal_papers_show_last = journal_papers_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count]
|
journal_papers_show = journal_papers_temp.select {|value| value.journal_paper_author_types.collect{|jat| jat.title}.join(", ").include? params[:keywords]}
|
||||||
journal_papers = journal_papers_show_last
|
else
|
||||||
|
journal_papers_show = journal_papers_temp.select {|value| value.send(params[:selectbox]).to_s.include? params[:keywords]}
|
||||||
|
end
|
||||||
|
if params[:page_no].nil?
|
||||||
|
page_to_show = 1
|
||||||
|
else
|
||||||
|
page_to_show = params[:page_no].to_i
|
||||||
|
end
|
||||||
|
journal_papers_show_last = journal_papers_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count]
|
||||||
|
journal_papers = journal_papers_show_last
|
||||||
|
journal_papers_total_pages = (journal_papers_show.length/OrbitHelper.page_data_count.to_f).ceil
|
||||||
else
|
else
|
||||||
|
journal_papers_total_pages = journal_papers.total_pages
|
||||||
end
|
end
|
||||||
journal_paper_list = []
|
journal_paper_list = []
|
||||||
journal_papers.each do |journal_paper|
|
journal_papers.each do |journal_paper|
|
||||||
|
@ -95,7 +97,7 @@ class PersonalJournalsController < ApplicationController
|
||||||
"journal_papers" => journal_paper_list,
|
"journal_papers" => journal_paper_list,
|
||||||
"headers" => headers,
|
"headers" => headers,
|
||||||
"extras" => {"widget-title" => t("module_name.journal_paper")},
|
"extras" => {"widget-title" => t("module_name.journal_paper")},
|
||||||
"total_pages" => journal_papers.total_pages,
|
"total_pages" => journal_papers_total_pages,
|
||||||
"choice" => {"choice_value" => choice_value ,"choice_show" => choice_show},
|
"choice" => {"choice_value" => choice_value ,"choice_show" => choice_show},
|
||||||
"url" => "/"+params[:locale]+params[:url],
|
"url" => "/"+params[:locale]+params[:url],
|
||||||
"all" => journal_papers_show_last
|
"all" => journal_papers_show_last
|
||||||
|
|
Loading…
Reference in New Issue