From 92784c5f2caf78068443904ebe616f61b4ef81d5 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Wed, 19 Apr 2017 00:55:15 -0300 Subject: [PATCH] FIX: Show solved status on category lists too --- plugin.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugin.rb b/plugin.rb index 6f1c8a1..c5a7730 100644 --- a/plugin.rb +++ b/plugin.rb @@ -385,6 +385,24 @@ SQL end end + class ::ListableTopicSerializer + attributes :has_accepted_answer, :can_have_answer + + def has_accepted_answer + object.custom_fields["accepted_answer_post_id"] ? true : false + end + + def can_have_answer + return true if SiteSetting.allow_solved_on_all_topics + return false if object.closed || object.archived + return scope.allow_accepted_answers_on_category?(object.category_id) + end + + def include_can_have_answer? + SiteSetting.empty_box_on_unsolved + end + end + TopicList.preloaded_custom_fields << "accepted_answer_post_id" if TopicList.respond_to? :preloaded_custom_fields end