From d09391f88771d038f583a38faefacee20c02267c Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 1 Oct 2015 18:36:21 +0800 Subject: [PATCH] sort fix for top --- app/controllers/announcements_controller.rb | 2 +- app/models/bulletin.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 54798ea..8c59c69 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -92,7 +92,7 @@ class AnnouncementsController < ApplicationController def widget uid = OrbitHelper.params[:uid] rescue "" tags = ["all"] if OrbitHelper.widget_tags.empty? - announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil],:uid.ne => uid).and(:title.ne => nil).is_approved.order_by(:postdate=>'desc').can_display.filter_by_widget_categories.filter_by_tags(tags) + announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil],:uid.ne => uid).and(:title.ne => nil).can_display.is_approved.filter_by_widget_categories.filter_by_tags(tags) page = Page.where(:module => "announcement").first rescue nil anns = announcements.collect do |a| statuses = a.statuses_with_classname.collect do |status| diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index c097221..fcfee99 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -39,7 +39,7 @@ class Bulletin before_destroy :destroy_email - scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc])} + scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])} scope :is_approved, ->{where(:approved => true)} before_create :set_expire