diff --git a/app/assets/javascripts/admin/controllers/admin_flags_controller.js.coffee b/app/assets/javascripts/admin/controllers/admin_flags_controller.js.coffee index c1f0e781b8f..99f8e3439f1 100644 --- a/app/assets/javascripts/admin/controllers/admin_flags_controller.js.coffee +++ b/app/assets/javascripts/admin/controllers/admin_flags_controller.js.coffee @@ -7,6 +7,13 @@ window.Discourse.AdminFlagsController = Ember.Controller.extend bootbox.alert("something went wrong") ) + deletePost: (item) -> + item.deletePost().then (=> + @content.removeObject(item) + ), (-> + bootbox.alert("something went wrong") + ) + adminOldFlagsView: (-> @query == 'old' ).property('query') diff --git a/app/assets/javascripts/admin/models/flagged_post.js.coffee b/app/assets/javascripts/admin/models/flagged_post.js.coffee index 6d3f0fa0bc3..cc35232c7bd 100644 --- a/app/assets/javascripts/admin/models/flagged_post.js.coffee +++ b/app/assets/javascripts/admin/models/flagged_post.js.coffee @@ -28,6 +28,25 @@ window.Discourse.FlaggedPost = Discourse.Post.extend @get('topic_visible') == 'f' ).property('topic_hidden') + deletePost: -> + promise = new RSVP.Promise() + if @get('post_number') == "1" + $.ajax "/t/#{@topic_id}", + type: 'DELETE' + cache: false + success: -> + promise.resolve() + error: (e)-> + promise.reject() + else + $.ajax "/posts/#{@id}", + type: 'DELETE' + cache: false + success: -> + promise.resolve() + error: (e)-> + promise.reject() + clearFlags: -> promise = new RSVP.Promise() $.ajax "/admin/flags/clear/#{@id}", diff --git a/app/assets/javascripts/admin/templates/flags.js.handlebars b/app/assets/javascripts/admin/templates/flags.js.handlebars index cf567f32310..929076b5cec 100644 --- a/app/assets/javascripts/admin/templates/flags.js.handlebars +++ b/app/assets/javascripts/admin/templates/flags.js.handlebars @@ -21,14 +21,15 @@ {{#each content}} - {{avatar user imageSize="small"}} + {{avatar user imageSize="small"}} {{#if topicHidden}} {{/if}}

{{title}}


{{{excerpt}}} - {{#each flaggers}}{{avatar this imageSize="small"}}{{/each}} + {{#each flaggers}}{{avatar this imageSize="small"}}{{/each}} {{date lastFlagged}} {{#if controller.adminActiveFlagsView}} - + + {{/if}} diff --git a/config/locales/en.yml b/config/locales/en.yml index dd0527f53f8..8969f1442b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -314,6 +314,10 @@ en: title: "Flags" old: "Old" active: "Active" + clear: "Clear Flags" + clear_title: "dismiss all flags on this post (will unhide hidden posts)" + delete: "Delete Post" + delete_title: "delete post (if its the first post delete topic)" customize: title: "Customize" diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 00196c4bd5b..ec698f02e0a 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -63,15 +63,10 @@ describe Post do post = Fabricate(:post) user = Fabricate(:coding_horror) PostAction.act(user, post, PostActionType.Types[:off_topic]) - PostAction.act(post.user, post, PostActionType.Types[:spam]) post.reload post.is_flagged?.should == true - PostAction.remove_act(post.user, post, PostActionType.Types[:spam]) - post.reload - post.is_flagged?.should == true - PostAction.remove_act(user, post, PostActionType.Types[:off_topic]) post.reload post.is_flagged?.should == false