mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Allow to change ownership on deleted users' posts
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import Presence from 'discourse/mixins/presence';
|
||||
import SelectedPostsCount from 'discourse/mixins/selected-posts-count';
|
||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
import ObjectController from 'discourse/controllers/object';
|
||||
|
||||
// Modal related to changing the ownership of posts
|
||||
export default ObjectController.extend(Presence, SelectedPostsCount, ModalFunctionality, {
|
||||
export default Ember.Controller.extend(Presence, SelectedPostsCount, ModalFunctionality, {
|
||||
needs: ['topic'],
|
||||
|
||||
topicController: Em.computed.alias('controllers.topic'),
|
||||
selectedPosts: Em.computed.alias('topicController.selectedPosts'),
|
||||
saving: false,
|
||||
new_user: null,
|
||||
|
||||
buttonDisabled: function() {
|
||||
if (this.get('saving')) return true;
|
||||
@@ -38,7 +39,7 @@ export default ObjectController.extend(Presence, SelectedPostsCount, ModalFuncti
|
||||
username: this.get('new_user')
|
||||
};
|
||||
|
||||
Discourse.Topic.changeOwners(this.get('id'), saveOpts).then(function(result) {
|
||||
Discourse.Topic.changeOwners(this.get('topicController.model.id'), saveOpts).then(function(result) {
|
||||
// success
|
||||
self.send('closeModal');
|
||||
self.get('topicController').send('toggleMultiSelect');
|
||||
|
||||
@@ -400,7 +400,7 @@ class Post < ActiveRecord::Base
|
||||
return if user_id == new_user.id
|
||||
|
||||
edit_reason = I18n.t('change_owner.post_revision_text',
|
||||
old_user: self.user.username_lower,
|
||||
old_user: (self.user.username_lower rescue nil) || I18n.t('change_owner.deleted_user'),
|
||||
new_user: new_user.username_lower
|
||||
)
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@ class PostOwnerChanger
|
||||
@post_ids.each do |post_id|
|
||||
post = Post.with_deleted.find(post_id)
|
||||
@topic.user = @new_owner if post.is_first_post?
|
||||
|
||||
if post.user == nil
|
||||
post.recover!
|
||||
@topic.recover! if post.is_first_post?
|
||||
end
|
||||
post.topic = @topic
|
||||
post.set_owner(@new_owner, @acting_user)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user