CLEANUP: remove 'contains_messages' leftover 💩

This commit is contained in:
Régis Hanol 2016-01-12 11:29:26 +01:00
parent 96aa5b865f
commit 8049dfdfda
12 changed files with 10 additions and 37 deletions

View File

@ -22,7 +22,6 @@ export default ComboboxView.extend({
return categories.filter(c => { return categories.filter(c => {
if (scopedCategoryId && c.get('id') !== scopedCategoryId && c.get('parent_category_id') !== scopedCategoryId) { return false; } if (scopedCategoryId && c.get('id') !== scopedCategoryId && c.get('parent_category_id') !== scopedCategoryId) { return false; }
if (c.get('isUncategorizedCategory')) { return false; } if (c.get('isUncategorizedCategory')) { return false; }
if (c.get('contains_messages')) { return false; }
return c.get('permission') === PermissionType.FULL; return c.get('permission') === PermissionType.FULL;
}); });
}, },

View File

@ -90,12 +90,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
this.set('selectedReplies', []); this.set('selectedReplies', []);
}.on('init'), }.on('init'),
@computed("model.isPrivateMessage", "model.category_id") showCategoryChooser: Ember.computed.not("model.isPrivateMessage"),
showCategoryChooser(isPrivateMessage, categoryId) {
const category = Discourse.Category.findById(categoryId);
const containsMessages = category && category.get("contains_messages");
return !isPrivateMessage && !containsMessages;
},
gotoInbox(name) { gotoInbox(name) {
var url = '/users/' + this.get('currentUser.username_lower') + '/messages'; var url = '/users/' + this.get('currentUser.username_lower') + '/messages';

View File

@ -87,7 +87,6 @@ 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'),
contains_messages: this.get("contains_messages"),
}, },
type: this.get('id') ? 'PUT' : 'POST' type: this.get('id') ? 'PUT' : 'POST'
}); });

View File

@ -67,12 +67,10 @@ const Composer = RestModel.extend({
creatingPrivateMessage: Em.computed.equal('action', PRIVATE_MESSAGE), creatingPrivateMessage: Em.computed.equal('action', PRIVATE_MESSAGE),
notCreatingPrivateMessage: Em.computed.not('creatingPrivateMessage'), notCreatingPrivateMessage: Em.computed.not('creatingPrivateMessage'),
@computed("privateMessage", "archetype.hasOptions", "categoryId") @computed("privateMessage", "archetype.hasOptions")
showCategoryChooser(isPrivateMessage, hasOptions, categoryId) { showCategoryChooser(isPrivateMessage, hasOptions) {
const manyCategories = Discourse.Category.list().length > 1; const manyCategories = Discourse.Category.list().length > 1;
const category = Discourse.Category.findById(categoryId); return !isPrivateMessage && (hasOptions || manyCategories);
const containsMessages = category && category.get("contains_messages");
return !isPrivateMessage && !containsMessages && (hasOptions || manyCategories);
}, },
privateMessage: function(){ privateMessage: function(){

View File

@ -20,12 +20,6 @@
</section> </section>
{{#if emailInEnabled}} {{#if emailInEnabled}}
<section class='field'>
<label>
{{input type="checkbox" checked=category.contains_messages}}
{{i18n 'category.contains_messages'}}
</label>
</section>
<section class='field'> <section class='field'>
<label> <label>
{{input type="checkbox" checked=category.email_in_allow_strangers}} {{input type="checkbox" checked=category.email_in_allow_strangers}}

View File

@ -178,7 +178,6 @@ class CategoriesController < ApplicationController
:position, :position,
:email_in, :email_in,
:email_in_allow_strangers, :email_in_allow_strangers,
:contains_messages,
:suppress_from_homepage, :suppress_from_homepage,
:parent_category_id, :parent_category_id,
:auto_close_hours, :auto_close_hours,

View File

@ -474,7 +474,6 @@ 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)
# contains_messages :boolean default(FALSE), not null
# #
# Indexes # Indexes
# #

View File

@ -544,7 +544,6 @@ class Topic < ActiveRecord::Base
def change_category_to_id(category_id) def change_category_to_id(category_id)
return false if private_message? return false if private_message?
return false if category.try(:contains_messages)
new_category_id = category_id.to_i new_category_id = category_id.to_i
# if the category name is blank, reset the attribute # if the category name is blank, reset the attribute

View File

@ -19,8 +19,7 @@ class BasicCategorySerializer < ApplicationSerializer
:background_url, :background_url,
:can_edit, :can_edit,
:topic_template, :topic_template,
:has_children, :has_children
:contains_messages
def include_parent_category_id? def include_parent_category_id?
parent_category_id parent_category_id

View File

@ -1631,7 +1631,6 @@ en:
email_in_allow_strangers: "Accept emails from anonymous users with no accounts" email_in_allow_strangers: "Accept emails from anonymous users with no accounts"
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.'
contains_messages: "Change this category to only contain messages."
suppress_from_homepage: "Suppress this category from the homepage." suppress_from_homepage: "Suppress this category from the homepage."
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"

View File

@ -0,0 +1,5 @@
class RemoveContainsMessageOnCategory < ActiveRecord::Migration
def change
remove_column :categories, :contains_messages
end
end

View File

@ -898,18 +898,6 @@ describe TopicsController do
end end
end end
context 'when topic is in support category' do
let(:another_category) { Fabricate(:category) }
it "cannot change the category of a topic that is in a support category" do
@topic.category = Fabricate(:category, contains_messages: true)
@topic.save!
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category_id: another_category.id
expect(response).not_to be_success
end
end
context "allow_uncategorized_topics is false" do context "allow_uncategorized_topics is false" do
before do before do
SiteSetting.stubs(:allow_uncategorized_topics).returns(false) SiteSetting.stubs(:allow_uncategorized_topics).returns(false)