added filter start and end date options
This commit is contained in:
parent
30687d655f
commit
cf5c45cb34
|
@ -65,10 +65,27 @@ class AnnouncementFeedsController < ApplicationController
|
||||||
|
|
||||||
def get_announcements(uid)
|
def get_announcements(uid)
|
||||||
bf = BulletinFeed.find_by(:uid => uid) rescue nil
|
bf = BulletinFeed.find_by(:uid => uid) rescue nil
|
||||||
|
startdt = params[:start]
|
||||||
|
enddt = params[:end]
|
||||||
|
dt = params[:date]
|
||||||
if !bf.nil?
|
if !bf.nil?
|
||||||
tags = bf.tag_ids
|
tags = bf.tag_ids
|
||||||
if !tags.empty?
|
if !tags.empty?
|
||||||
|
if !dt.nil?
|
||||||
|
dt = DateTime.parse(dt)
|
||||||
|
dtt = dt + 1.day
|
||||||
|
announcements = Bulletin.where(:postdate.gt => dt, :postdate.lt => dtt).can_display.is_approved.filter_by_tags(tags)
|
||||||
|
elsif !startdt.nil? && enddt.nil?
|
||||||
|
startdt = DateTime.parse(startdt)
|
||||||
|
enddt = DateTime.now
|
||||||
|
announcements = Bulletin.where(:postdate.gt => startdt, :postdate.lt => enddt).can_display.is_approved.filter_by_tags(tags)
|
||||||
|
elsif !startdt.nil? && !enddt.nil?
|
||||||
|
startdt = DateTime.parse(startdt)
|
||||||
|
enddt = DateTime.parse(enddt) + 1.day
|
||||||
|
announcements = Bulletin.where(:postdate.gt => startdt, :postdate.lt => enddt).can_display.is_approved.filter_by_tags(tags)
|
||||||
|
else
|
||||||
announcements = Bulletin.all.can_display.is_approved.filter_by_tags(tags)
|
announcements = Bulletin.all.can_display.is_approved.filter_by_tags(tags)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
announcements = []
|
announcements = []
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue