Fixes some minor issues with users deleting their own posts.
This commit is contained in:
parent
b8ded55450
commit
2d064571df
|
@ -304,10 +304,12 @@ Discourse.TopicController = Ember.ObjectController.extend Discourse.Presence,
|
|||
post.recover()
|
||||
|
||||
deletePost: (post) ->
|
||||
if post.get('user_id') is Discourse.get('currentUser.id')
|
||||
# Moderators can delete posts. Regular users can only create a deleted at message.
|
||||
if Discourse.get('currentUser.moderator')
|
||||
post.set('deleted_at', new Date())
|
||||
else
|
||||
post.set('cooked', Discourse.Utilities.cook(Em.String.i18n("post.deleted_by_author")))
|
||||
post.set('can_delete', false)
|
||||
else
|
||||
post.set('deleted_at', new Date())
|
||||
post.set('version', post.get('version') + 1)
|
||||
|
||||
post.delete()
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
class CurrentUserSerializer < BasicUserSerializer
|
||||
|
||||
attributes :name, :unread_notifications, :unread_private_messages, :admin, :notification_channel_position, :site_flagged_posts_count
|
||||
attributes :name,
|
||||
:unread_notifications,
|
||||
:unread_private_messages,
|
||||
:admin?,
|
||||
:notification_channel_position,
|
||||
:site_flagged_posts_count,
|
||||
:moderator?
|
||||
|
||||
# we probably want to move this into site, but that json is cached so hanging it off current user seems okish
|
||||
|
||||
|
@ -8,6 +14,10 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||
object.admin
|
||||
end
|
||||
|
||||
def moderator?
|
||||
object.has_trust_level?(:moderator)
|
||||
end
|
||||
|
||||
def site_flagged_posts_count
|
||||
PostAction.flagged_posts_count
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue