From edf9d8a1597bd5c15fed080a60c01d31bbbde4fa Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 16 Aug 2012 18:55:34 +0800 Subject: [PATCH] Fix can_display --- .../panel/announcement/front_end/bulletins_controller.rb | 4 ++-- vendor/built_in_modules/announcement/app/models/bulletin.rb | 2 +- .../panel/news/front_end/news_bulletins_controller.rb | 4 ++-- vendor/built_in_modules/news/app/models/news_bulletin.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index a828d42a..a5cad78d 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -30,7 +30,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController date_now = Time.now if !params[:category_id].blank? && !params[:tag_id].blank? @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(id: params[:tag_id])[0] unless @tag + @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag @bulletins = @tag.bulletins.available_for_lang(I18n.locale).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(15) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:category_id].blank? @@ -38,7 +38,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController @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(id: params[:tag_id])[0] unless @tag + @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag @bulletins = @tag.bulletins.available_for_lang(I18n.locale).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(15) else @bulletins = Bulletin.all.available_for_lang(I18n.locale).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(15) diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 352db55c..adc50101 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -43,7 +43,7 @@ class Bulletin field :public, :type => Boolean, :default => true - scope :can_display,all_of(is_checked: true,is_rejected: false,is_pending: false) + scope :can_display, where(is_checked: true, is_rejected: false, is_pending: false) scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } mount_uploader :image, ImageUploader diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb index 502f78b7..0e9f0ac3 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb @@ -31,7 +31,7 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController date_now = Time.now if !params[:category_id].blank? && !params[:tag_id].blank? @tag = NewsTag.find(params[:tag_id]) rescue nil - @tag = NewsTag.where(id: params[:tag_id])[0] unless @tag + @tag = NewsTag.where(key: params[:tag_id])[0] unless @tag @news_bulletins = @tag.news_bulletins.available_for_lang(I18n.locale).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(15) @current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:category_id].blank? @@ -39,7 +39,7 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController @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(id: params[:tag_id])[0] unless @tag + @tag = NewsTag.where(key: params[:tag_id])[0] unless @tag @news_bulletins = @tag.news_bulletins.available_for_lang(I18n.locale).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(15) else @news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).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(15) diff --git a/vendor/built_in_modules/news/app/models/news_bulletin.rb b/vendor/built_in_modules/news/app/models/news_bulletin.rb index eeabbcab..974d55a7 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -43,7 +43,7 @@ class NewsBulletin field :public, :type => Boolean, :default => true - scope :can_display,all_of(is_checked: true,is_rejected: false,is_pending: false) + scope :can_display, where(is_checked: true, is_rejected: false, is_pending: false) scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } mount_uploader :image, ImageUploader