Fix can_display
This commit is contained in:
parent
3c283d1a7a
commit
edf9d8a159
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue