mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 05:01:14 +08:00
FEATURE: Category setting to make all topics wikis
FEATURE: Category setting to make all topics wikis
This commit is contained in:
@ -97,6 +97,7 @@ const Category = RestModel.extend({
|
|||||||
custom_fields: this.get('custom_fields'),
|
custom_fields: this.get('custom_fields'),
|
||||||
topic_template: this.get('topic_template'),
|
topic_template: this.get('topic_template'),
|
||||||
suppress_from_homepage: this.get('suppress_from_homepage'),
|
suppress_from_homepage: this.get('suppress_from_homepage'),
|
||||||
|
all_topics_wiki: this.get('all_topics_wiki'),
|
||||||
allowed_tags: this.get('allowed_tags'),
|
allowed_tags: this.get('allowed_tags'),
|
||||||
allowed_tag_groups: this.get('allowed_tag_groups'),
|
allowed_tag_groups: this.get('allowed_tag_groups'),
|
||||||
sort_order: this.get('sort_order'),
|
sort_order: this.get('sort_order'),
|
||||||
|
@ -19,6 +19,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="field">
|
||||||
|
<label>
|
||||||
|
{{input type="checkbox" checked=category.all_topics_wiki}}
|
||||||
|
{{i18n "category.all_topics_wiki"}}
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
{{#if siteSettings.topic_featured_link_enabled}}
|
{{#if siteSettings.topic_featured_link_enabled}}
|
||||||
<section class='field'>
|
<section class='field'>
|
||||||
<div class="allowed-topic-featured-link-category">
|
<div class="allowed-topic-featured-link-category">
|
||||||
|
@ -230,6 +230,7 @@ class CategoriesController < ApplicationController
|
|||||||
:email_in,
|
:email_in,
|
||||||
:email_in_allow_strangers,
|
:email_in_allow_strangers,
|
||||||
:suppress_from_homepage,
|
:suppress_from_homepage,
|
||||||
|
:all_topics_wiki,
|
||||||
:parent_category_id,
|
:parent_category_id,
|
||||||
:auto_close_hours,
|
:auto_close_hours,
|
||||||
:auto_close_based_on_last_post,
|
:auto_close_based_on_last_post,
|
||||||
|
@ -538,6 +538,7 @@ end
|
|||||||
# auto_close_based_on_last_post :boolean default(FALSE)
|
# auto_close_based_on_last_post :boolean default(FALSE)
|
||||||
# topic_template :text
|
# topic_template :text
|
||||||
# suppress_from_homepage :boolean default(FALSE)
|
# suppress_from_homepage :boolean default(FALSE)
|
||||||
|
# all_topics_wiki :boolean default(FALSE)
|
||||||
# contains_messages :boolean
|
# contains_messages :boolean
|
||||||
# sort_order :string
|
# sort_order :string
|
||||||
# sort_ascending :boolean
|
# sort_ascending :boolean
|
||||||
|
@ -9,6 +9,7 @@ class CategorySerializer < BasicCategorySerializer
|
|||||||
:email_in,
|
:email_in,
|
||||||
:email_in_allow_strangers,
|
:email_in_allow_strangers,
|
||||||
:suppress_from_homepage,
|
:suppress_from_homepage,
|
||||||
|
:all_topics_wiki,
|
||||||
:can_delete,
|
:can_delete,
|
||||||
:cannot_delete_reason,
|
:cannot_delete_reason,
|
||||||
:is_special,
|
:is_special,
|
||||||
|
@ -1944,6 +1944,7 @@ en:
|
|||||||
email_in_disabled: "Posting new topics via email is disabled in the Site Settings. To enable posting new topics via email, "
|
email_in_disabled: "Posting new topics via email is disabled in the Site Settings. To enable posting new topics via email, "
|
||||||
email_in_disabled_click: 'enable the "email in" setting.'
|
email_in_disabled_click: 'enable the "email in" setting.'
|
||||||
suppress_from_homepage: "Suppress this category from the homepage."
|
suppress_from_homepage: "Suppress this category from the homepage."
|
||||||
|
all_topics_wiki: "Make new topics wikis by default."
|
||||||
sort_order: "Default Sort:"
|
sort_order: "Default Sort:"
|
||||||
allow_badges_label: "Allow badges to be awarded in this category"
|
allow_badges_label: "Allow badges to be awarded in this category"
|
||||||
edit_permissions: "Edit Permissions"
|
edit_permissions: "Edit Permissions"
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddAllTopicsWikiToCategories < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :categories, :all_topics_wiki, :boolean, default: false, null: false
|
||||||
|
end
|
||||||
|
end
|
@ -25,7 +25,7 @@ module ImportExport
|
|||||||
|
|
||||||
CATEGORY_ATTRS = [:id, :name, :color, :created_at, :user_id, :slug, :description, :text_color,
|
CATEGORY_ATTRS = [:id, :name, :color, :created_at, :user_id, :slug, :description, :text_color,
|
||||||
:auto_close_hours, :auto_close_based_on_last_post,
|
:auto_close_hours, :auto_close_based_on_last_post,
|
||||||
:topic_template, :suppress_from_homepage, :permissions_params]
|
:topic_template, :suppress_from_homepage, :all_topics_wiki, :permissions_params]
|
||||||
|
|
||||||
def export_categories
|
def export_categories
|
||||||
@export_data[:category] = CATEGORY_ATTRS.inject({}) { |h,a| h[a] = @category.send(a); h }
|
@export_data[:category] = CATEGORY_ATTRS.inject({}) { |h,a| h[a] = @category.send(a); h }
|
||||||
|
@ -361,6 +361,9 @@ class PostCreator
|
|||||||
end
|
end
|
||||||
@post.topic_id = @topic.id
|
@post.topic_id = @topic.id
|
||||||
@post.topic = @topic
|
@post.topic = @topic
|
||||||
|
if @topic && @topic.category && @topic.category.all_topics_wiki
|
||||||
|
@post.wiki = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_topic_stats
|
def update_topic_stats
|
||||||
|
@ -34,6 +34,14 @@ describe PostCreator do
|
|||||||
expect(TopicUser.where(user_id: p.user_id, topic_id: p.topic_id).count).to eq(0)
|
expect(TopicUser.where(user_id: p.user_id, topic_id: p.topic_id).count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "can be created with first post as wiki" do
|
||||||
|
cat = Fabricate(:category)
|
||||||
|
cat.all_topics_wiki = true
|
||||||
|
cat.save
|
||||||
|
post = PostCreator.create(user, basic_topic_params.merge(category: cat.id ))
|
||||||
|
expect(post.wiki).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
it "ensures the user can create the topic" do
|
it "ensures the user can create the topic" do
|
||||||
Guardian.any_instance.expects(:can_create?).with(Topic,nil).returns(false)
|
Guardian.any_instance.expects(:can_create?).with(Topic,nil).returns(false)
|
||||||
expect { creator.create }.to raise_error(Discourse::InvalidAccess)
|
expect { creator.create }.to raise_error(Discourse::InvalidAccess)
|
||||||
|
Reference in New Issue
Block a user