From 2c72a8852d8b999873ad818ffab45850b95eabf7 Mon Sep 17 00:00:00 2001
From: nccu <nccu@test174.(none)>
Date: Fri, 13 Feb 2015 10:01:01 +0800
Subject: [PATCH] fix widget can_display

---
 app/controllers/news_controller.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 2488c5b..120dffb 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -107,7 +107,7 @@ class NewsController < ApplicationController
   def widget
     params = OrbitHelper.params
     !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"}
-    news = NewsBulletin.where(:title.ne => "",:is_preview.in=>[false,nil],:is_hot => true).is_approved.order_by(sort).filter_by_widget_categories if news.nil?
+    news = NewsBulletin.where(:title.ne => "",:is_preview.in=>[false,nil],:is_hot => true).can_display.is_approved.order_by(sort).filter_by_widget_categories if news.nil?
 
     page = Page.where(:module => "news").first rescue nil
     ma = ModuleApp.find_by_key("news") rescue nil
@@ -204,8 +204,8 @@ class NewsController < ApplicationController
         "title" => HTMLEntities.new.encode(news.title),
         "category" => news.category.title,
         "category-link" => "/#{I18n.locale.to_s + page.url}/?category=#{news.category.to_param}",
-        "unit" => news.unit.name,
-        "unit-link" => "/#{I18n.locale.to_s + page.url}/?unit=#{news.unit.to_param}",
+        "unit" => (news.unit.name rescue ""),
+        "unit-link" => "/#{I18n.locale.to_s + page.url}/?unit=#{(news.unit.to_param rescue "")}",
         "department" => (department.name rescue ""),
         "department-link" => "/#{I18n.locale.to_s + page.url}/?department=#{(department.to_param rescue "")}",
         "update_user" => update_user,