fix for missing disable category at frontend and widget

This commit is contained in:
Matthew K. Fu JuYuan 2012-07-17 11:26:50 +08:00
parent dcf3150deb
commit 033667f99b
4 changed files with 11 additions and 11 deletions

View File

@ -12,14 +12,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
date_now = Time.now
if !params[:category_id].blank?
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
@bulletins = Bulletin.all.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
@bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
else
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
@bulletins = Bulletin.all.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
end
end
@ -28,7 +28,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
if params[:preview] == "true"
preview_content
else
@bulletin = Bulletin.can_display.where(_id: params[:id]).first
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
unless @bulletin.disable?
impressionist(@bulletin)
get_categorys

View File

@ -11,14 +11,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@title = params[:part_title]
date_now = Time.now
if !params[:category_id].blank?
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
@bulletins = Bulletin.all.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
@bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
else
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
@bulletins = Bulletin.all.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
end
get_categorys

View File

@ -25,17 +25,17 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
#raise to_curl
end.results.collect{|t| t.id}
@news_bulletins = NewsBulletin.can_display.any_in(_id:search_result).page( params[:page_main]).per(10)
@news_bulletins = NewsBulletin.all.can_display.any_in(_id:search_result).page( params[:page_main]).per(10)
else
date_now = Time.now
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
@news_bulletins = NewsBulletin.all.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
elsif !params[:tag_id].blank?
tmp = NewsTag.find(params[:tag_id]) rescue nil
tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp
@news_bulletins = tmp.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) rescue nil
else
@news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
@news_bulletins = NewsBulletin.all.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
end
end
get_categorys
@ -48,7 +48,7 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
if params[:preview] == "true"
preview_content
else
@news_bulletin = NewsBulletin.can_display.where(_id: params[:id]).first
@news_bulletin = NewsBulletin.all.can_display.where(_id: params[:id]).first
unless @news_bulletin.disable?
impressionist(@news_bulletin)
get_categorys

View File

@ -13,14 +13,14 @@ caches_page :home_banner
@title = params[:part_title]
date_now = Time.now
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
@news_bulletins = NewsBulletin.all.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
@current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = NewsTag.find(params[:tag_id]) rescue nil
@tag = NewsTag.where(key: params[:tag_id])[0] unless @tag
@news_bulletins = @tag.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5) rescue nil
else
@news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
@news_bulletins = NewsBulletin.all.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
end
end