class NewsTag < Tag
  has_and_belongs_to_many :news_bulletins
    
  def get_visible_news_bulletins(sort = :title)
    date_now = Time.now
	  self.news_bulletins.where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort)
  end
  
  def news_bulletins
      NewsBulletin.all.any_in(:_id => news_bulletin_ids)
  end

end