This commit is contained in:
nccu 2014-11-11 10:58:22 +08:00
parent 0c1fc57f15
commit 569ee6b18b
1 changed files with 17 additions and 7 deletions

View File

@ -19,8 +19,14 @@ class AnnouncementsController < ApplicationController
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
announcements = Bulletin.where(:title.ne => "" ,:is_preview.in=>[false,nil]).is_approved.order_by(sort).filter_by_categories(["all"]).filter_by_tags([params[:tag]])
else
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
announcements = Bulletin.where(:title.ne => "" ,:is_preview.in=>[false,nil]).is_approved.order_by(sort).filter_by_categories.filter_by_tags(params['tags'])
sort = ( !params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:postdate=>"desc"})
# announcements = Bulletin.where(:title.ne => "" ,:is_preview.in=>[false,nil]).can_display.is_approved.order_by(sort).filter_by_categories.filter_by_tags(OrbitHelper.page_tags)
if OrbitHelper.page_categories.first == "all"
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).is_approved.order_by(sort).filter_by_tags.page(params[:page_no]).per(OrbitHelper.page_data_count)
else
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).is_approved.filter_by_categories.filter_by_tags.can_display.order_by(sort).page(params[:page_no]).per(OrbitHelper.page_data_count)
end
end
page = Page.where(:module => "announcement").first rescue nil
ma = ModuleApp.find_by_key("announcement") rescue nil
@ -37,7 +43,7 @@ class AnnouncementsController < ApplicationController
end
tags.each do |t|
percent = (t["count"].to_i * 100) / max_tag_count
if percent >= 75
if percent >= 75
t["tag-class"] = "hot1"
elsif percent >= 50
t["tag-class"] = "hot2"
@ -70,7 +76,7 @@ class AnnouncementsController < ApplicationController
"statuses" => statuses,
"category" => a.category.title,
"postdate" => a.postdate,
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"link_to_show" => (params[:page_id] == "visitors" ? "/#{I18n.locale.to_s + page.url}/#{a.to_param}" : OrbitHelper.url_to_show(a.to_param)),
"img_src" => a.image.thumb.url || "http://placehold.it/100x100",
"img_description" => a.image_description,
"more" => t(:more_plus)
@ -98,7 +104,10 @@ class AnnouncementsController < ApplicationController
end
def widget
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).can_display.is_approved.order_by(:created_at=>'desc').filter_by_widget_categories.filter_by_tags(OrbitHelper.widget_tags)
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).can_display.is_approved.order_by(:postdate=>'desc').filter_by_widget_categories.filter_by_tags(OrbitHelper.widget_tags)
# announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil], :category_id.in => OrbitHelper.widget_categories).can_display.is_approved.order_by(:postdate=>'desc').filter_by_tags(OrbitHelper.widget_tags).limit(OrbitHelper.widget_data_count)
# params = OrbitHelper.params
# announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil], :category_id.in => OrbitHelper.widget_categories).can_display.is_approved.order_by(:postdate=>'desc').filter_by_tags(OrbitHelper.widget_tags).page(params[:page_no]).per(OrbitHelper.widget_data_count) rescue nil
anns = announcements.collect do |a|
statuses = a.statuses_with_classname.collect do |status|
@ -126,7 +135,8 @@ class AnnouncementsController < ApplicationController
"date-head" => t('announcement.table.date'),
"status-head" => t('announcement.table.status'),
"subtitle-head" => t('announcement.table.sub_title'),
"category-head" => t('announcement.table.category')
"category-head" => t('announcement.table.category'),
"total_pages" => announcements.total_pages
}
}
end
@ -163,7 +173,7 @@ class AnnouncementsController < ApplicationController
end
tags.each do |t|
percent = (t["count"].to_i * 100) / max_tag_count
if percent >= 75
if percent >= 75
t["tag-class"] = "hot1"
elsif percent >= 50
t["tag-class"] = "hot2"