Fixed Showpaper page display
This commit is contained in:
parent
fd5d23a86c
commit
b0ff05a0a4
|
|
@ -131,18 +131,53 @@ class EPapersController < ApplicationController
|
|||
|
||||
def showpaper
|
||||
params = OrbitHelper.params
|
||||
if params[:uid].present?
|
||||
criteria = PaperCriteria.where(:uid => params[:uid]).first
|
||||
return if criteria.nil?
|
||||
end
|
||||
return {} if params[:uid].blank?
|
||||
|
||||
criteria = PaperCriteria.where(:uid => params[:uid]).first
|
||||
return {} if criteria.nil?
|
||||
|
||||
banner_image = nil
|
||||
if criteria.banner_image.present?
|
||||
banner_image = EPaperImage.find(criteria.banner_image).image.url
|
||||
end
|
||||
|
||||
|
||||
topics = EPaperTopic.where(
|
||||
:period.gte => criteria.start_date,
|
||||
:period.lte => criteria.end_date
|
||||
).desc(:period)
|
||||
|
||||
papers = topics.group_by(&:category)
|
||||
|
||||
data = []
|
||||
papers_sorted = get_all_categories.map do |v|
|
||||
tmp = papers.select{|cat,topic_list| (cat.id==v.id rescue false)}
|
||||
tmp.count==0 ? nil : tmp
|
||||
end.compact
|
||||
|
||||
papers_sorted.each do |paper|
|
||||
paper.each do |category, topic_list|
|
||||
topics_data = Array(topic_list).compact.collect do |topic|
|
||||
{
|
||||
"title" => topic.title,
|
||||
"link_to_show" => OrbitHelper.url_to_show(topic.to_param),
|
||||
"description" => topic.description,
|
||||
"img_url" => topic.image.url || EmptyImgUrl,
|
||||
"img_url_thumb" => topic.image.thumb.url || EmptyImgUrl,
|
||||
"category_title" => category.title
|
||||
}
|
||||
end
|
||||
data << {
|
||||
"category_title" => category.title,
|
||||
"category_link" => "#{params["url"]}/#{params["page"]}?method=topics&category=#{category.id.to_s}",
|
||||
"topics" => topics_data
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
{
|
||||
"title" => criteria.title,
|
||||
"banner_image" => banner_image,
|
||||
"content" => criteria.content,
|
||||
"description" => criteria.description
|
||||
"categories" => data,
|
||||
"extras" => {}
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue