Can show announcement and news list by tag's key

This commit is contained in:
Christophe Vilayphiou 2012-05-08 17:27:42 +08:00
parent 5c7cf1aef2
commit 55bfaea43e
4 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,8 @@ class Tag
include Mongoid::Document
include Mongoid::Timestamps
field :key
belongs_to :module_app
end

View File

@ -14,7 +14,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
if !params[:category_id].blank?
@bulletins = Bulletin.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]).per(10)
elsif !params[:tag_id].blank?
@bulletins = AnnouncementTag.find(params[:tag_id]).bulletins.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]).per(10)
tmp = NewsTag.find(params[:tag_id]) rescue nil
tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp
@bulletins = tmp.bulletins.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]).per(10) rescue nil
else
@bulletins = Bulletin.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]).per(10)
end

View File

@ -26,7 +26,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
end
def bulletins_and_web_links
@tags = AnnouncementTag.all
@tags = AnnouncementTag.any_in(key: ['students', 'alumni', 'employee', 'guest'])
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil

View File

@ -13,7 +13,9 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.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]).per(10)
elsif !params[:tag_id].blank?
@news_bulletins = NewsTag.find(params[:tag_id]).news_bulletins.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]).per(10)
tmp = NewsTag.find(params[:tag_id]) rescue nil
tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp
@news_bulletins = tmp.news_bulletins.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]).per(10) rescue nil
else
@news_bulletins = NewsBulletin.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]).per(10)
end