From 24ef9c848c6b48f5170cded492d5ccaf9306f8ab Mon Sep 17 00:00:00 2001 From: spen Date: Fri, 21 Mar 2014 14:42:06 +0800 Subject: [PATCH] Fix approval --- app/models/bulletin.rb | 3 +++ lib/announcement.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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