From 6e6b1c968968fb933a3248a897914ccaea349ad6 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 11 Dec 2014 17:42:26 +0800 Subject: [PATCH] category fix --- app/controllers/announcements_controller.rb | 2 ++ app/views/admin/announcements/_index.html.erb | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index ebd2ece..8bdbd72 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -82,6 +82,8 @@ class AnnouncementsController < ApplicationController return {} end + return {} if announcement.category.disable + tags = announcement.tags.map{|tag| { "tag" => tag.name , "url" => OrbitHelper.page_for_tag(tag) diff --git a/app/views/admin/announcements/_index.html.erb b/app/views/admin/announcements/_index.html.erb index b321dd3..dca66ce 100644 --- a/app/views/admin/announcements/_index.html.erb +++ b/app/views/admin/announcements/_index.html.erb @@ -16,14 +16,28 @@ <%= b.status_for_table %> - <%= b.category.title %> + + <%= b.category.title rescue "" %> + <% if (b.category.disable rescue false) %> + <%= t(:disabled) %> + <% end %> + <% if b.expired? %> <%= b.title %> <%= t(:expired) %> <% elsif !b.approved? %> - <%= b.title %> <%= t(:pending) %> + <% if (b.category.disable rescue false) %> + <%= b.title %> + <% else %> + <%= b.title %> + <% end %> + <%= t(:pending) %> <% else %> - <%= b.title %> + <% if (b.category.disable rescue false) %> + <%= b.title %> + <% else %> + <%= b.title %> + <% end %> <% end %>