BUGFIX: PMs could be created with a category
BUGFIX: hide category column when displaying the list of private messages
This commit is contained in:
parent
0634f3320a
commit
245bc19379
|
@ -7,6 +7,7 @@
|
|||
@module Discourse
|
||||
**/
|
||||
Discourse.UserTopicsListController = Discourse.ObjectController.extend({
|
||||
hideCategory: false,
|
||||
|
||||
actions: {
|
||||
loadMore: function() {
|
||||
|
|
|
@ -4,9 +4,12 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({
|
|||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
this.controllerFor('user_activity').set('userActionType', this.get('userActionType'));
|
||||
this.controllerFor('user_topics_list').set('model', model);
|
||||
this.controllerFor('user').set('indexStream', false);
|
||||
this.controllerFor('user_activity').set('userActionType', this.get('userActionType'));
|
||||
this.controllerFor('user_topics_list').setProperties({
|
||||
model: model,
|
||||
hideCategory: false
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -20,6 +23,7 @@ function createPMRoute(viewName, path) {
|
|||
|
||||
setupController: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.controllerFor('user_topics_list').set('hideCategory', true);
|
||||
this.controllerFor('user').setProperties({
|
||||
pmView: viewName,
|
||||
indexStream: false
|
||||
|
|
|
@ -1 +1 @@
|
|||
{{basic-topic-list topicList=model}}
|
||||
{{basic-topic-list topicList=model hideCategory=hideCategory}}
|
||||
|
|
|
@ -47,10 +47,20 @@ class TopicCreator
|
|||
end
|
||||
|
||||
def setup
|
||||
topic_params = {title: @opts[:title], user_id: @user.id, last_post_user_id: @user.id}
|
||||
topic_params[:archetype] = @opts[:archetype] if @opts[:archetype].present?
|
||||
topic_params = {
|
||||
title: @opts[:title],
|
||||
user_id: @user.id,
|
||||
last_post_user_id: @user.id
|
||||
}
|
||||
|
||||
topic_params[:subtype] = @opts[:subtype] if @opts[:subtype].present?
|
||||
|
||||
if @opts[:archetype].present?
|
||||
topic_params[:archetype] = @opts[:archetype]
|
||||
# PM can't have a category
|
||||
@opts.delete(:category) if topic_params[:archetype] == Archetype.private_message
|
||||
end
|
||||
|
||||
# Temporary fix to allow older clients to create topics.
|
||||
# When all clients are updated the category variable should
|
||||
# be set directly to the contents of the if statement.
|
||||
|
@ -59,10 +69,13 @@ class TopicCreator
|
|||
else
|
||||
Category.where(name: @opts[:category]).first
|
||||
end
|
||||
|
||||
@guardian.ensure_can_create!(Topic,category)
|
||||
|
||||
topic_params[:category_id] = category.id if category.present?
|
||||
topic_params[:meta_data] = @opts[:meta_data] if @opts[:meta_data].present?
|
||||
topic_params[:created_at] = Time.zone.parse(@opts[:created_at].to_s) if @opts[:created_at].present?
|
||||
|
||||
topic_params
|
||||
end
|
||||
|
||||
|
|
|
@ -313,13 +313,17 @@ describe PostCreator do
|
|||
PostCreator.create(user, title: 'hi there welcome to my topic',
|
||||
raw: "this is my awesome message @#{unrelated.username_lower}",
|
||||
archetype: Archetype.private_message,
|
||||
target_usernames: [target_user1.username, target_user2.username].join(','))
|
||||
target_usernames: [target_user1.username, target_user2.username].join(','),
|
||||
category: 1)
|
||||
end
|
||||
|
||||
it 'acts correctly' do
|
||||
post.topic.archetype.should == Archetype.private_message
|
||||
post.topic.topic_allowed_users.count.should == 3
|
||||
|
||||
# PMs can't have a category
|
||||
post.topic.category.should be_nil
|
||||
|
||||
# does not notify an unrelated user
|
||||
unrelated.notifications.count.should == 0
|
||||
post.topic.subtype.should == TopicSubtype.user_to_user
|
||||
|
|
Loading…
Reference in New Issue