Show who deleted a topic

This commit is contained in:
Robin Ward 2013-07-12 16:38:21 -04:00
parent 0c7ead339b
commit 2aa487d2c8
4 changed files with 24 additions and 6 deletions

View File

@ -17,6 +17,20 @@ Discourse.Post = Discourse.Model.extend({
new_user: Em.computed.equal('trust_level', 0),
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() {
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'),
@ -173,6 +187,7 @@ Discourse.Post = Discourse.Model.extend({
}
},
/**
Recover a deleted post

View File

@ -56,9 +56,9 @@
{{view Discourse.RepliesView contentBinding="replies" postViewBinding="view"}}
{{view Discourse.ActionsHistoryView contentBinding="actionsHistory"}}
{{#if deleted_by}}
{{#if deleted}}
<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>
{{/if}}

View File

@ -12,7 +12,7 @@ Discourse.PostView = Discourse.View.extend({
classNameBindings: ['postTypeClass',
'selected',
'post.hidden:hidden',
'deleted',
'post.deleted',
'parentPost:replies-above'],
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() {
var selectedPosts = this.get('controller.selectedPosts');

View File

@ -31,7 +31,8 @@ class TopicViewSerializer < ApplicationSerializer
:pinned,
:details,
:highest_post_number,
:last_read_post_number
:last_read_post_number,
:deleted_by
# Define a delegator for each attribute of the topic we want
attributes *topic_attributes
@ -108,6 +109,10 @@ class TopicViewSerializer < ApplicationSerializer
object.draft_sequence
end
def deleted_by
BasicUserSerializer.new(object.topic.deleted_by, root: false).as_json
end
# Topic user stuff
def has_topic_user?
object.topic_user.present?