Fixed Showpaper page display
This commit is contained in:
parent
fd5d23a86c
commit
b0ff05a0a4
|
|
@ -131,18 +131,53 @@ class EPapersController < ApplicationController
|
||||||
|
|
||||||
def showpaper
|
def showpaper
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
if params[:uid].present?
|
return {} if params[:uid].blank?
|
||||||
criteria = PaperCriteria.where(:uid => params[:uid]).first
|
|
||||||
return if criteria.nil?
|
criteria = PaperCriteria.where(:uid => params[:uid]).first
|
||||||
end
|
return {} if criteria.nil?
|
||||||
|
|
||||||
|
banner_image = nil
|
||||||
if criteria.banner_image.present?
|
if criteria.banner_image.present?
|
||||||
banner_image = EPaperImage.find(criteria.banner_image).image.url
|
banner_image = EPaperImage.find(criteria.banner_image).image.url
|
||||||
end
|
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,
|
"categories" => data,
|
||||||
"banner_image" => banner_image,
|
"extras" => {}
|
||||||
"content" => criteria.content,
|
|
||||||
"description" => criteria.description
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue