From c15ed696b82ccb0636cee84dce4ab0e2897b3d46 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 18 Jun 2014 14:32:57 +0800 Subject: [PATCH] added tags and statuses to faq --- app/controllers/faqs_controller.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controllers/faqs_controller.rb b/app/controllers/faqs_controller.rb index c4c176e..3b8e3cd 100644 --- a/app/controllers/faqs_controller.rb +++ b/app/controllers/faqs_controller.rb @@ -1,20 +1,28 @@ class FaqsController < ApplicationController def index - faqs = Qa.filter_by_categories.collect do |qa| + faqs = Qa.can_display.order_by(:created_at=>'desc').filter_by_categories.collect do |qa| + statuses = qa.statuses.collect do |status| + { + "status" => status, + "status-class" => "status-#{status.downcase}" + } + end { "link_to_show" => OrbitHelper.url_to_show(qa.to_param), - "question" => qa.title + "question" => qa.title, + "statuses" => statuses } end { "data" => faqs, "extras" => {"widget-title"=>"Faqs"} + "total_pages" => faqs.total_pages } end def show params = OrbitHelper.params - faq = Qa.find_by_param(params[:uid]) + faq = Qa.can_display.find_by_param(params[:uid]) faqs_files = faq.qa_files.collect do |f| { "file_url" => f.file.url, @@ -27,10 +35,12 @@ class FaqsController < ApplicationController "link_title" => f.title } end + tags = faq.tags.map{|tag| { "tag" => tag.name } } rescue [] { "extras" => {"question" => faq.title,"answer" => faq.answer}, "faqs_links" => faqs_links, - "faqs_files" => faqs_files + "faqs_files" => faqs_files, + "tags" => tags } end