fix announcement deadline

This commit is contained in:
nccu 2014-12-29 17:18:06 +08:00
parent e7b9e076cc
commit 6df7981ad1
1 changed files with 5 additions and 5 deletions

View File

@ -7,25 +7,25 @@ class AnnouncementsController < ApplicationController
if params[:keywords] if params[:keywords]
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"} !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
announcements = Bulletin.where(:title.ne => "").any_of(:title => /#{params[:keywords].to_s}/i).is_approved.order_by(sort).filter_by_categories(["all"]).per(15) if !params[:keywords].nil? announcements = Bulletin.where(:title.ne => "").any_of(:title => /#{params[:keywords].to_s}/i).can_display.is_approved.order_by(sort).filter_by_categories(["all"]).per(15) if !params[:keywords].nil?
announcements_count = announcements.count announcements_count = announcements.count
keyword = params[:keywords] keyword = params[:keywords]
elsif params[:unit] elsif params[:unit]
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"} !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
announcements = Bulletin.where(:title.ne => "" ,:cache_dept => params[:unit].to_s).is_approved.order_by(sort).filter_by_categories(["all"]).per(15) if !params[:unit].nil? announcements = Bulletin.where(:title.ne => "" ,:cache_dept => params[:unit].to_s).can_display.is_approved.order_by(sort).filter_by_categories(["all"]).per(15) if !params[:unit].nil?
announcements_count = announcements.count announcements_count = announcements.count
keyword = params[:unit] keyword = params[:unit]
elsif params[:tag] elsif params[:tag]
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"} !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]]) announcements = Bulletin.where(:title.ne => "" ,:is_preview.in=>[false,nil]).can_display.is_approved.order_by(sort).filter_by_categories(["all"]).filter_by_tags([params[:tag]])
else else
sort = ( !params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:postdate=>"desc"}) 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) # 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" 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) announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).can_display.is_approved.order_by(sort).filter_by_tags.page(params[:page_no]).per(OrbitHelper.page_data_count)
else 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) announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).can_display.is_approved.filter_by_categories.filter_by_tags.can_display.order_by(sort).page(params[:page_no]).per(OrbitHelper.page_data_count)
end end
end end
page = Page.where(:module => "announcement").first rescue nil page = Page.where(:module => "announcement").first rescue nil