2019-05-12 23:04:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-13 13:10:54 -04:00
|
|
|
module TopicAnswerMixin
|
|
|
|
def self.included(klass)
|
|
|
|
klass.attributes :has_accepted_answer, :can_have_answer
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_accepted_answer
|
|
|
|
object.custom_fields["accepted_answer_post_id"] ? true : false
|
|
|
|
end
|
|
|
|
|
2019-03-18 08:32:55 -04:00
|
|
|
def include_has_accepted_answer?
|
|
|
|
SiteSetting.solved_enabled
|
|
|
|
end
|
|
|
|
|
2019-03-13 13:10:54 -04:00
|
|
|
def can_have_answer
|
|
|
|
return true if SiteSetting.allow_solved_on_all_topics
|
|
|
|
return false if object.closed || object.archived
|
2021-09-17 21:07:01 -04:00
|
|
|
scope.allow_accepted_answers?(object.category_id, object.tags.map(&:name))
|
2019-03-13 13:10:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_can_have_answer?
|
2019-03-18 08:32:55 -04:00
|
|
|
SiteSetting.solved_enabled && SiteSetting.empty_box_on_unsolved
|
2019-03-13 13:10:54 -04:00
|
|
|
end
|
|
|
|
end
|