mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-07-05 13:22:11 +00:00
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'>
|
<section class='field'>
|
||||||
<div class="enable-accepted-answer">
|
<div class="enable-accepted-answer">
|
||||||
<label class="checkbox-label">
|
<label class="checkbox-label">
|
||||||
@ -6,3 +7,4 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
{{/unless}}
|
||||||
|
@ -3,7 +3,7 @@ import PostView from 'discourse/views/post';
|
|||||||
import { Button } from 'discourse/views/post-menu';
|
import { Button } from 'discourse/views/post-menu';
|
||||||
import Topic from 'discourse/models/topic';
|
import Topic from 'discourse/models/topic';
|
||||||
import User from 'discourse/models/user';
|
import User from 'discourse/models/user';
|
||||||
import TopicStatus from 'discourse/views/topic-status'
|
import TopicStatus from 'discourse/views/topic-status';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'extend-for-solved-button',
|
name: 'extend-for-solved-button',
|
||||||
@ -17,7 +17,7 @@ export default {
|
|||||||
var fields = this.get('custom_fields');
|
var fields = this.get('custom_fields');
|
||||||
return fields && (fields.enable_accepted_answers === "true");
|
return fields && (fields.enable_accepted_answers === "true");
|
||||||
}.property('custom_fields')
|
}.property('custom_fields')
|
||||||
}),
|
});
|
||||||
|
|
||||||
Topic.reopen({
|
Topic.reopen({
|
||||||
|
|
||||||
|
3
config/locales/server.en.yml
Normal file
3
config/locales/server.en.yml
Normal file
@ -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)"
|
4
config/settings.yml
Normal file
4
config/settings.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
plugins:
|
||||||
|
allow_solved_on_all_topics:
|
||||||
|
default: false
|
||||||
|
client: true
|
@ -138,6 +138,8 @@ after_initialize do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allow_accepted_answers_on_category?(category_id)
|
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"]
|
self.class.reset_accepted_answer_cache unless @@allowed_accepted_cache["allowed"]
|
||||||
@@allowed_accepted_cache["allowed"].include?(category_id)
|
@@allowed_accepted_cache["allowed"].include?(category_id)
|
||||||
end
|
end
|
||||||
@ -157,6 +159,7 @@ after_initialize do
|
|||||||
|
|
||||||
def can_accept_answer
|
def can_accept_answer
|
||||||
topic = (topic_view && topic_view.topic) || object.topic
|
topic = (topic_view && topic_view.topic) || object.topic
|
||||||
|
|
||||||
if topic
|
if topic
|
||||||
scope.can_accept_answer?(topic) &&
|
scope.can_accept_answer?(topic) &&
|
||||||
object.post_number > 1 && !accepted_answer
|
object.post_number > 1 && !accepted_answer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user