Add sorting order for NCCU request

This commit is contained in:
Matthew K. Fu JuYuan 2012-07-03 15:47:28 +08:00
parent 4014f8ee47
commit 4fe92b844e
3 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,12 @@
require 'resque_scheduler/tasks'
# encoding: utf-8
namespace :data_migration do
task :add_order_to_announcement_tag_0703 => :environment do
AnnouncementTag.first({conditions:{ key: 'students' }}).update_attributes(:order=>1)
AnnouncementTag.first({conditions:{ key: 'alumni' }}).update_attributes(:order=>2)
AnnouncementTag.first({conditions:{ key: 'employee' }}).update_attributes(:order=>3)
AnnouncementTag.first({conditions:{ key: 'guest' }}).update_attributes(:order=>4)
end
end

View File

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

View File

@ -1,7 +1,7 @@
class AnnouncementTag < Tag class AnnouncementTag < Tag
has_and_belongs_to_many :bulletins has_and_belongs_to_many :bulletins
field :order,:default => 0
def get_visible_bulletins(sort = :name) def get_visible_bulletins(sort = :name)
date_now = Time.now date_now = Time.now