mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: allow staff members to restore withdrawn posts that are flagged
This commit is contained in:
parent
c9dea9ce5c
commit
79030c874e
5 changed files with 29 additions and 31 deletions
|
@ -2,37 +2,25 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
|||
import ObjectController from 'discourse/controllers/object';
|
||||
|
||||
export default ObjectController.extend(ModalFunctionality, {
|
||||
|
||||
needs: ["adminFlags"],
|
||||
|
||||
_agreeFlag: function (actionOnPost) {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
return post.agreeFlags(actionOnPost).then(function () {
|
||||
adminFlagController.removeObject(post);
|
||||
self.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
agreeFlagHidePost: function () {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
return post.agreeFlags("hide").then(function () {
|
||||
adminFlagController.removeObject(post);
|
||||
self.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
});
|
||||
},
|
||||
|
||||
agreeFlagKeepPost: function () {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
return post.agreeFlags("keep").then(function () {
|
||||
adminFlagController.removeObject(post);
|
||||
self.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
});
|
||||
}
|
||||
|
||||
agreeFlagHidePost: function () { return this._agreeFlag("hide"); },
|
||||
agreeFlagKeepPost: function () { return this._agreeFlag("keep"); },
|
||||
agreeFlagRestorePost: function () { return this._agreeFlag("restore"); }
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
{{#unless postHidden}}
|
||||
<button title="{{i18n admin.flags.agree_flag_hide_post_title}}" {{action agreeFlagHidePost}} class="btn"><i class="fa fa-thumbs-o-up"></i><i class="fa fa-eye-slash"></i>{{i18n admin.flags.agree_flag_hide_post}}</button>
|
||||
{{/unless}}
|
||||
{{#if user_deleted}}
|
||||
<button title="{{i18n admin.flags.agree_flag_restore_post_title}}" {{action agreeFlagRestorePost}} class="btn"><i class="fa fa-thumbs-o-up"></i><i class="fa fa-eye"></i>{{i18n admin.flags.agree_flag_restore_post}}</button>
|
||||
{{else}}
|
||||
{{#unless postHidden}}
|
||||
<button title="{{i18n admin.flags.agree_flag_hide_post_title}}" {{action agreeFlagHidePost}} class="btn"><i class="fa fa-thumbs-o-up"></i><i class="fa fa-eye-slash"></i>{{i18n admin.flags.agree_flag_hide_post}}</button>
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
<button title="{{i18n admin.flags.agree_flag_title}}" {{action agreeFlagKeepPost}} class="btn"><i class="fa fa-thumbs-o-up"></i>{{i18n admin.flags.agree_flag}}</button>
|
||||
{{#if canDeleteAsSpammer}}
|
||||
<button title="{{i18n admin.flags.delete_spammer_title}}" {{action deleteSpammer user}} class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i>{{i18n admin.flags.delete_spammer}}</button>
|
||||
|
|
|
@ -26,11 +26,14 @@ class Admin::FlagsController < Admin::AdminController
|
|||
|
||||
keep_post = params[:action_on_post] == "keep"
|
||||
delete_post = params[:action_on_post] == "delete"
|
||||
restore_post = params[:action_on_post] == "restore"
|
||||
|
||||
PostAction.agree_flags!(post, current_user, delete_post)
|
||||
|
||||
if delete_post
|
||||
PostDestroyer.new(current_user, post).destroy
|
||||
elsif restore_post
|
||||
PostDestroyer.new(current_user, post).recover
|
||||
elsif !keep_post
|
||||
PostAction.hide_post!(post, post_action_type)
|
||||
end
|
||||
|
|
|
@ -1498,6 +1498,8 @@ en:
|
|||
agree_flag_modal_title: "Agree and..."
|
||||
agree_flag_hide_post: "Agree (hide post + send PM)"
|
||||
agree_flag_hide_post_title: "Hide this post and automatically send the user a private message urging them to edit it"
|
||||
agree_flag_restore_post: "Agree (restore post)"
|
||||
agree_flag_restore_post_title: "Restore this post"
|
||||
agree_flag: "Agree with flag"
|
||||
agree_flag_title: "Agree with flag and keep the post unchanged"
|
||||
defer_flag: "Defer"
|
||||
|
|
|
@ -26,6 +26,7 @@ module FlagQuery
|
|||
p.post_number,
|
||||
p.hidden,
|
||||
p.deleted_at,
|
||||
p.user_deleted,
|
||||
(SELECT created_at FROM post_revisions WHERE post_id = p.id AND user_id = p.user_id ORDER BY created_at DESC LIMIT 1) AS last_revised_at,
|
||||
(SELECT COUNT(*) FROM post_actions WHERE (disagreed_at IS NOT NULL OR agreed_at IS NOT NULL OR deferred_at IS NOT NULL) AND post_id = p.id)::int AS previous_flags_count
|
||||
FROM posts p
|
||||
|
|
Loading…
Reference in a new issue