mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #1488 from cfstras/removeAllowedUser
Allow removing users from private conversations
This commit is contained in:
commit
578ef2098b
5 changed files with 30 additions and 3 deletions
|
@ -476,8 +476,19 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
},
|
||||
|
||||
removeAllowedUser: function(username) {
|
||||
this.get('details').removeAllowedUser(username);
|
||||
var self = this;
|
||||
bootbox.dialog(I18n.t("private_message_info.remove_allowed_user", {name: username}), [
|
||||
{label: I18n.t("no_value"),
|
||||
'class': 'btn-danger rightg'},
|
||||
{label: I18n.t("yes_value"),
|
||||
'class': 'btn-primary',
|
||||
callback: function() {
|
||||
self.get('details').removeAllowedUser(username);
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,15 @@ Discourse.TopicDetails = Discourse.Model.extend({
|
|||
type: 'POST',
|
||||
data: { notification_level: v }
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
removeAllowedUser: function(username) {
|
||||
var users = this.get('allowed_users');
|
||||
Discourse.ajax("/t/" + this.get('topic.id') + "/remove-allowed-user", {
|
||||
type: 'PUT',
|
||||
data: { username: username }
|
||||
}).then(function(res) {
|
||||
users.removeObject(users.findProperty('username', username));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -382,7 +382,12 @@ class Topic < ActiveRecord::Base
|
|||
def remove_allowed_user(username)
|
||||
user = User.where(username: username).first
|
||||
if user
|
||||
topic_allowed_users.where(user_id: user.id).first.destroy
|
||||
topic_user = topic_allowed_users.where(user_id: user.id).first
|
||||
if topic_user
|
||||
topic_user.destroy
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -373,6 +373,7 @@ de:
|
|||
private_message_info:
|
||||
title: "Privates Gespräch"
|
||||
invite: "Andere einladen..."
|
||||
remove_allowed_user: "Willst du {{name}} wirklich aus diesem Gespräch entfernen?"
|
||||
|
||||
email: 'Mail'
|
||||
username: 'Benutzername'
|
||||
|
|
|
@ -372,6 +372,7 @@ en:
|
|||
private_message_info:
|
||||
title: "Private Message"
|
||||
invite: "Invite Others..."
|
||||
remove_allowed_user: "Do you really want to remove {{name}} from this private message?"
|
||||
|
||||
email: 'Email'
|
||||
username: 'Username'
|
||||
|
|
Loading…
Reference in a new issue