mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
Show who deleted a topic
This commit is contained in:
parent
0c7ead339b
commit
2aa487d2c8
@ -17,6 +17,20 @@ Discourse.Post = Discourse.Model.extend({
|
|||||||
new_user: Em.computed.equal('trust_level', 0),
|
new_user: Em.computed.equal('trust_level', 0),
|
||||||
firstPost: Em.computed.equal('post_number', 1),
|
firstPost: Em.computed.equal('post_number', 1),
|
||||||
|
|
||||||
|
// Posts can show up as deleted if the topic is deleted
|
||||||
|
deletedViaTopic: Em.computed.and('firstPost', 'topic.deleted_at'),
|
||||||
|
deleted: Em.computed.or('deleted_at', 'deletedViaTopic'),
|
||||||
|
|
||||||
|
postDeletedBy: function() {
|
||||||
|
if (this.get('firstPost')) { return this.get('topic.deleted_by') }
|
||||||
|
return this.get('deleted_by');
|
||||||
|
}.property('firstPost', 'deleted_by', 'topic.deleted_by'),
|
||||||
|
|
||||||
|
postDeletedAt: function() {
|
||||||
|
if (this.get('firstPost')) { return this.get('topic.deleted_at') }
|
||||||
|
return this.get('deleted_at');
|
||||||
|
}.property('firstPost', 'deleted_at', 'topic.deleted_at'),
|
||||||
|
|
||||||
url: function() {
|
url: function() {
|
||||||
return Discourse.Utilities.postUrl(this.get('topic.slug') || this.get('topic_slug'), this.get('topic_id'), this.get('post_number'));
|
return Discourse.Utilities.postUrl(this.get('topic.slug') || this.get('topic_slug'), this.get('topic_id'), this.get('post_number'));
|
||||||
}.property('post_number', 'topic_id', 'topic.slug'),
|
}.property('post_number', 'topic_id', 'topic.slug'),
|
||||||
@ -173,6 +187,7 @@ Discourse.Post = Discourse.Model.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Recover a deleted post
|
Recover a deleted post
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@
|
|||||||
{{view Discourse.RepliesView contentBinding="replies" postViewBinding="view"}}
|
{{view Discourse.RepliesView contentBinding="replies" postViewBinding="view"}}
|
||||||
{{view Discourse.ActionsHistoryView contentBinding="actionsHistory"}}
|
{{view Discourse.ActionsHistoryView contentBinding="actionsHistory"}}
|
||||||
|
|
||||||
{{#if deleted_by}}
|
{{#if deleted}}
|
||||||
<div class='post-actions'>
|
<div class='post-actions'>
|
||||||
{{i18n post.deleted_by}} {{avatar deleted_by imageSize="tiny"}} {{unboundAge deleted_at}}
|
{{i18n post.deleted_by}} {{avatar postDeletedBy imageSize="tiny"}} {{unboundAge postDeletedAt}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ Discourse.PostView = Discourse.View.extend({
|
|||||||
classNameBindings: ['postTypeClass',
|
classNameBindings: ['postTypeClass',
|
||||||
'selected',
|
'selected',
|
||||||
'post.hidden:hidden',
|
'post.hidden:hidden',
|
||||||
'deleted',
|
'post.deleted',
|
||||||
'parentPost:replies-above'],
|
'parentPost:replies-above'],
|
||||||
postBinding: 'content',
|
postBinding: 'content',
|
||||||
|
|
||||||
@ -39,8 +39,6 @@ Discourse.PostView = Discourse.View.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deletedViaTopic: Em.computed.and('post.firstPost', 'post.topic.deleted_at'),
|
|
||||||
deleted: Em.computed.or('post.deleted_at', 'deletedViaTopic'),
|
|
||||||
|
|
||||||
selected: function() {
|
selected: function() {
|
||||||
var selectedPosts = this.get('controller.selectedPosts');
|
var selectedPosts = this.get('controller.selectedPosts');
|
||||||
|
@ -31,7 +31,8 @@ class TopicViewSerializer < ApplicationSerializer
|
|||||||
:pinned,
|
:pinned,
|
||||||
:details,
|
:details,
|
||||||
:highest_post_number,
|
:highest_post_number,
|
||||||
:last_read_post_number
|
:last_read_post_number,
|
||||||
|
:deleted_by
|
||||||
|
|
||||||
# Define a delegator for each attribute of the topic we want
|
# Define a delegator for each attribute of the topic we want
|
||||||
attributes *topic_attributes
|
attributes *topic_attributes
|
||||||
@ -108,6 +109,10 @@ class TopicViewSerializer < ApplicationSerializer
|
|||||||
object.draft_sequence
|
object.draft_sequence
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deleted_by
|
||||||
|
BasicUserSerializer.new(object.topic.deleted_by, root: false).as_json
|
||||||
|
end
|
||||||
|
|
||||||
# Topic user stuff
|
# Topic user stuff
|
||||||
def has_topic_user?
|
def has_topic_user?
|
||||||
object.topic_user.present?
|
object.topic_user.present?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user