2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
This controller supports the interface for dealing with flags in the admin section.
|
|
|
|
|
2013-03-15 06:03:13 +08:00
|
|
|
@class AdminFlagsController
|
2013-02-23 04:41:12 +08:00
|
|
|
@extends Ember.Controller
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
2013-03-15 06:03:13 +08:00
|
|
|
**/
|
2013-05-21 03:27:58 +08:00
|
|
|
Discourse.AdminFlagsController = Ember.ArrayController.extend({
|
2013-03-15 06:03:13 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
actions: {
|
|
|
|
/**
|
|
|
|
Clear all flags on a post
|
2013-02-23 04:41:12 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
@method clearFlags
|
|
|
|
@param {Discourse.FlaggedPost} item The post whose flags we want to clear
|
|
|
|
**/
|
|
|
|
disagreeFlags: function(item) {
|
|
|
|
var adminFlagsController = this;
|
2014-02-13 12:01:12 +08:00
|
|
|
item.disagreeFlags().then(function() {
|
2013-09-17 02:08:55 +08:00
|
|
|
adminFlagsController.removeObject(item);
|
2014-02-13 12:01:12 +08:00
|
|
|
}, function() {
|
2013-09-17 02:08:55 +08:00
|
|
|
bootbox.alert(I18n.t("admin.flags.error"));
|
|
|
|
});
|
|
|
|
},
|
2013-02-23 04:41:12 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
agreeFlags: function(item) {
|
|
|
|
var adminFlagsController = this;
|
2014-02-13 12:01:12 +08:00
|
|
|
item.agreeFlags().then(function() {
|
2013-09-17 02:08:55 +08:00
|
|
|
adminFlagsController.removeObject(item);
|
2014-02-13 12:01:12 +08:00
|
|
|
}, function() {
|
2013-09-17 02:08:55 +08:00
|
|
|
bootbox.alert(I18n.t("admin.flags.error"));
|
|
|
|
});
|
|
|
|
},
|
2013-06-20 15:42:15 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
deferFlags: function(item) {
|
|
|
|
var adminFlagsController = this;
|
2014-02-13 12:01:12 +08:00
|
|
|
item.deferFlags().then(function() {
|
2013-09-17 02:08:55 +08:00
|
|
|
adminFlagsController.removeObject(item);
|
2014-02-13 12:01:12 +08:00
|
|
|
}, function() {
|
2013-09-17 02:08:55 +08:00
|
|
|
bootbox.alert(I18n.t("admin.flags.error"));
|
|
|
|
});
|
|
|
|
},
|
2013-06-21 05:20:08 +08:00
|
|
|
|
2014-02-06 06:54:16 +08:00
|
|
|
doneTopicFlags: function(item) {
|
|
|
|
this.send('disagreeFlags', item);
|
|
|
|
},
|
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
/**
|
|
|
|
Deletes a post
|
2013-02-23 04:41:12 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
@method deletePost
|
2013-10-02 22:59:57 +08:00
|
|
|
@param {Discourse.FlaggedPost} post The post to delete
|
2013-09-17 02:08:55 +08:00
|
|
|
**/
|
2013-10-02 22:59:57 +08:00
|
|
|
deletePost: function(post) {
|
2013-09-17 02:08:55 +08:00
|
|
|
var adminFlagsController = this;
|
2014-02-13 12:01:12 +08:00
|
|
|
post.deletePost().then(function() {
|
2013-10-02 22:59:57 +08:00
|
|
|
adminFlagsController.removeObject(post);
|
2014-02-13 12:01:12 +08:00
|
|
|
}, function() {
|
2013-09-17 02:08:55 +08:00
|
|
|
bootbox.alert(I18n.t("admin.flags.error"));
|
|
|
|
});
|
|
|
|
},
|
2013-02-23 04:41:12 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
/**
|
|
|
|
Deletes a user and all posts and topics created by that user.
|
2013-07-27 03:40:08 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
@method deleteSpammer
|
|
|
|
@param {Discourse.FlaggedPost} item The post to delete
|
|
|
|
**/
|
|
|
|
deleteSpammer: function(item) {
|
|
|
|
item.get('user').deleteAsSpammer(function() { window.location.reload(); });
|
|
|
|
}
|
2013-07-27 03:40:08 +08:00
|
|
|
},
|
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
Are we viewing the 'old' view?
|
|
|
|
|
|
|
|
@property adminOldFlagsView
|
|
|
|
**/
|
2013-05-25 04:03:20 +08:00
|
|
|
adminOldFlagsView: Em.computed.equal('query', 'old'),
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2013-02-22 01:58:21 +08:00
|
|
|
/**
|
2013-02-23 04:41:12 +08:00
|
|
|
Are we viewing the 'active' view?
|
|
|
|
|
|
|
|
@property adminActiveFlagsView
|
|
|
|
**/
|
2013-08-19 19:14:26 +08:00
|
|
|
adminActiveFlagsView: Em.computed.equal('query', 'active'),
|
|
|
|
|
|
|
|
loadMore: function(){
|
|
|
|
var flags = this.get('model');
|
|
|
|
return Discourse.FlaggedPost.findAll(this.get('query'),flags.length+1).then(function(data){
|
|
|
|
if(data.length===0){
|
|
|
|
flags.set('allLoaded',true);
|
|
|
|
}
|
|
|
|
flags.addObjects(data);
|
|
|
|
});
|
|
|
|
}
|
2013-03-15 06:03:13 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|