added tags and statuses to faq

This commit is contained in:
Harry Bomrah 2014-06-18 14:32:57 +08:00
parent a456fe53da
commit c15ed696b8
1 changed files with 14 additions and 4 deletions

View File

@ -1,20 +1,28 @@
class FaqsController < ApplicationController class FaqsController < ApplicationController
def index 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), "link_to_show" => OrbitHelper.url_to_show(qa.to_param),
"question" => qa.title "question" => qa.title,
"statuses" => statuses
} }
end end
{ {
"data" => faqs, "data" => faqs,
"extras" => {"widget-title"=>"Faqs"} "extras" => {"widget-title"=>"Faqs"}
"total_pages" => faqs.total_pages
} }
end end
def show def show
params = OrbitHelper.params 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| faqs_files = faq.qa_files.collect do |f|
{ {
"file_url" => f.file.url, "file_url" => f.file.url,
@ -27,10 +35,12 @@ class FaqsController < ApplicationController
"link_title" => f.title "link_title" => f.title
} }
end end
tags = faq.tags.map{|tag| { "tag" => tag.name } } rescue []
{ {
"extras" => {"question" => faq.title,"answer" => faq.answer}, "extras" => {"question" => faq.title,"answer" => faq.answer},
"faqs_links" => faqs_links, "faqs_links" => faqs_links,
"faqs_files" => faqs_files "faqs_files" => faqs_files,
"tags" => tags
} }
end end