FEATURE: site setting to enable solved globally
This commit is contained in:
parent
ec6a5cd109
commit
d8705a278b
|
@ -1,3 +1,4 @@
|
|||
{{#unless siteSettings.allow_solved_on_all_topics}}
|
||||
<section class='field'>
|
||||
<div class="enable-accepted-answer">
|
||||
<label class="checkbox-label">
|
||||
|
@ -6,3 +7,4 @@
|
|||
</label>
|
||||
</div>
|
||||
</section>
|
||||
{{/unless}}
|
||||
|
|
|
@ -3,7 +3,7 @@ import PostView from 'discourse/views/post';
|
|||
import { Button } from 'discourse/views/post-menu';
|
||||
import Topic from 'discourse/models/topic';
|
||||
import User from 'discourse/models/user';
|
||||
import TopicStatus from 'discourse/views/topic-status'
|
||||
import TopicStatus from 'discourse/views/topic-status';
|
||||
|
||||
export default {
|
||||
name: 'extend-for-solved-button',
|
||||
|
@ -17,7 +17,7 @@ export default {
|
|||
var fields = this.get('custom_fields');
|
||||
return fields && (fields.enable_accepted_answers === "true");
|
||||
}.property('custom_fields')
|
||||
}),
|
||||
});
|
||||
|
||||
Topic.reopen({
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
en:
|
||||
site_settings:
|
||||
allow_solved_on_all_topics: "Allow users to select solutions on all topics (by default you control this by editing categories)"
|
|
@ -0,0 +1,4 @@
|
|||
plugins:
|
||||
allow_solved_on_all_topics:
|
||||
default: false
|
||||
client: true
|
|
@ -138,6 +138,8 @@ after_initialize do
|
|||
end
|
||||
|
||||
def allow_accepted_answers_on_category?(category_id)
|
||||
return true if SiteSetting.allow_solved_on_all_topics
|
||||
|
||||
self.class.reset_accepted_answer_cache unless @@allowed_accepted_cache["allowed"]
|
||||
@@allowed_accepted_cache["allowed"].include?(category_id)
|
||||
end
|
||||
|
@ -157,6 +159,7 @@ after_initialize do
|
|||
|
||||
def can_accept_answer
|
||||
topic = (topic_view && topic_view.topic) || object.topic
|
||||
|
||||
if topic
|
||||
scope.can_accept_answer?(topic) &&
|
||||
object.post_number > 1 && !accepted_answer
|
||||
|
|
Loading…
Reference in New Issue