From e0b0ffcd0937d2ecedee9bd354147bd683438c44 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 27 Apr 2016 18:55:14 +0800 Subject: [PATCH] added source filter --- app/controllers/announcements_controller.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 976e445..285c28e 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -8,9 +8,14 @@ class AnnouncementsController < ApplicationController if !params['tags'].blank? announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil).can_display.is_approved.filter_by_tags(params['tags']).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count).to_a else - announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil, :is_top.ne => true).can_display.is_approved.filter_by_categories([],false).filter_by_tags.to_a - - feeds_anns = get_feed_announcements("index") + + if !params["source"].present? + announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil, :is_top.ne => true).can_display.is_approved.filter_by_categories([],false).filter_by_tags.to_a + feeds_anns = get_feed_announcements("index") + else + announcements = [] + feeds_anns = get_feed_announcements("index",params["source"]) + end end if OrbitHelper.page_number == 1 or OrbitHelper.page_number.nil? @@ -73,7 +78,7 @@ class AnnouncementsController < ApplicationController "view_count" => a.view_count } else - anns << a + anns << a if a["source-site-title"] == params["source"] end end #If no data , hide title&table @@ -104,11 +109,12 @@ class AnnouncementsController < ApplicationController end - def get_feed_announcements(type) + def get_feed_announcements(type,source=nil) feed_anns = OrbitHelper.get_feed_for_module(type) fans = [] locale = OrbitHelper.get_site_locale.to_s feed_anns.each do |fa| + next if !source.nil? && source != fa["source-site-title"] status = { "status" => "#{fa["source-site-title"]}", "status-class" => "status-source"