diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index 3011b8e..e59b5f6 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -41,6 +41,9 @@ class Bulletin field :email_sentdate , :type => DateTime field :email_group, :type => Array field :other_mailaddress + + 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/lib/announcement.rb b/lib/announcement.rb index 85895dc..534feb1 100644 --- a/lib/announcement.rb +++ b/lib/announcement.rb @@ -28,13 +28,13 @@ module Announcement data_count 1..10 authorizable - # approvable + approvable categorizable taggable widgets do default_widget do - query 'Bulletin' + query 'Bulletin.can_display.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )' enable ["typeA", "typeB_style3", "typeC"] image :image field :postdate