diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index 15b653b91d2..742ac3973b1 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -230,6 +230,7 @@ class CategoriesController < ApplicationController
:email_in,
:email_in_allow_strangers,
:suppress_from_homepage,
+ :all_topics_wiki,
:parent_category_id,
:auto_close_hours,
:auto_close_based_on_last_post,
diff --git a/app/models/category.rb b/app/models/category.rb
index 7681188e8e3..458c24228ab 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -538,6 +538,7 @@ end
# auto_close_based_on_last_post :boolean default(FALSE)
# topic_template :text
# suppress_from_homepage :boolean default(FALSE)
+# all_topics_wiki :boolean default(FALSE)
# contains_messages :boolean
# sort_order :string
# sort_ascending :boolean
diff --git a/app/serializers/category_serializer.rb b/app/serializers/category_serializer.rb
index b3086fce5d6..beb7ae1d07b 100644
--- a/app/serializers/category_serializer.rb
+++ b/app/serializers/category_serializer.rb
@@ -9,6 +9,7 @@ class CategorySerializer < BasicCategorySerializer
:email_in,
:email_in_allow_strangers,
:suppress_from_homepage,
+ :all_topics_wiki,
:can_delete,
:cannot_delete_reason,
:is_special,
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index cfc18909205..8ebeaa12c52 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -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_click: 'enable the "email in" setting.'
suppress_from_homepage: "Suppress this category from the homepage."
+ all_topics_wiki: "Make new topics wikis by default."
sort_order: "Default Sort:"
allow_badges_label: "Allow badges to be awarded in this category"
edit_permissions: "Edit Permissions"
diff --git a/db/migrate/20161216101352_add_all_topics_wiki_to_categories.rb b/db/migrate/20161216101352_add_all_topics_wiki_to_categories.rb
new file mode 100644
index 00000000000..7d5fc430002
--- /dev/null
+++ b/db/migrate/20161216101352_add_all_topics_wiki_to_categories.rb
@@ -0,0 +1,5 @@
+class AddAllTopicsWikiToCategories < ActiveRecord::Migration
+ def change
+ add_column :categories, :all_topics_wiki, :boolean, default: false, null: false
+ end
+end
\ No newline at end of file
diff --git a/lib/import_export/category_exporter.rb b/lib/import_export/category_exporter.rb
index 745c9f9dbdb..9f182e72470 100644
--- a/lib/import_export/category_exporter.rb
+++ b/lib/import_export/category_exporter.rb
@@ -25,7 +25,7 @@ module ImportExport
CATEGORY_ATTRS = [:id, :name, :color, :created_at, :user_id, :slug, :description, :text_color,
: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
@export_data[:category] = CATEGORY_ATTRS.inject({}) { |h,a| h[a] = @category.send(a); h }
diff --git a/lib/post_creator.rb b/lib/post_creator.rb
index 98597091c55..1c9de20e6ea 100644
--- a/lib/post_creator.rb
+++ b/lib/post_creator.rb
@@ -360,6 +360,9 @@ class PostCreator
end
@post.topic_id = @topic.id
@post.topic = @topic
+ if @topic && @topic.category && @topic.category.all_topics_wiki
+ @post.wiki = true
+ end
end
def update_topic_stats
diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rb
index b6fe3fb6606..a0ba06c8818 100644
--- a/spec/components/post_creator_spec.rb
+++ b/spec/components/post_creator_spec.rb
@@ -34,6 +34,14 @@ describe PostCreator do
expect(TopicUser.where(user_id: p.user_id, topic_id: p.topic_id).count).to eq(0)
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
Guardian.any_instance.expects(:can_create?).with(Topic,nil).returns(false)
expect { creator.create }.to raise_error(Discourse::InvalidAccess)