2013-10-21 14:49:51 -04:00
|
|
|
/**
|
|
|
|
Represents an IP address that is watched for during account registration
|
|
|
|
(and possibly other times), and an action is taken.
|
|
|
|
|
|
|
|
@class ScreenedIpAddress
|
|
|
|
@extends Discourse.Model
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.ScreenedIpAddress = Discourse.Model.extend({
|
|
|
|
actionName: function() {
|
2013-10-24 17:18:10 -04:00
|
|
|
return I18n.t("admin.logs.screened_ips.actions." + this.get('action_name'));
|
|
|
|
}.property('action_name'),
|
2013-10-22 16:30:30 -04:00
|
|
|
|
|
|
|
isBlocked: function() {
|
2013-10-24 17:18:10 -04:00
|
|
|
return (this.get('action_name') === 'block');
|
|
|
|
}.property('action_name'),
|
2013-10-22 16:30:30 -04:00
|
|
|
|
|
|
|
actionIcon: function() {
|
2013-10-24 17:18:10 -04:00
|
|
|
if (this.get('action_name') === 'block') {
|
2013-10-22 16:30:30 -04:00
|
|
|
return this.get('blockIcon');
|
2013-10-21 14:49:51 -04:00
|
|
|
} else {
|
2013-10-22 16:30:30 -04:00
|
|
|
return this.get('doNothingIcon');
|
2013-10-21 14:49:51 -04:00
|
|
|
}
|
2013-10-24 17:18:10 -04:00
|
|
|
}.property('action_name'),
|
2013-10-22 16:30:30 -04:00
|
|
|
|
|
|
|
blockIcon: function() {
|
2013-12-09 16:27:49 -05:00
|
|
|
return 'fa-ban';
|
2013-10-22 16:30:30 -04:00
|
|
|
}.property(),
|
|
|
|
|
|
|
|
doNothingIcon: function() {
|
2013-12-09 16:27:49 -05:00
|
|
|
return 'fa-check';
|
2013-10-22 16:30:30 -04:00
|
|
|
}.property(),
|
|
|
|
|
|
|
|
save: function() {
|
2013-10-24 17:18:10 -04:00
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses" + (this.id ? '/' + this.id : '') + ".json", {
|
|
|
|
type: this.id ? 'PUT' : 'POST',
|
|
|
|
data: {ip_address: this.get('ip_address'), action_name: this.get('action_name')}
|
2013-10-22 16:30:30 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses/" + this.get('id') + ".json", {type: 'DELETE'});
|
|
|
|
}
|
2013-10-21 14:49:51 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
Discourse.ScreenedIpAddress.reopenClass({
|
2015-02-10 13:38:59 -05:00
|
|
|
findAll: function(filter) {
|
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses.json", { data: { filter: filter } }).then(function(screened_ips) {
|
2013-10-21 14:49:51 -04:00
|
|
|
return screened_ips.map(function(b) {
|
|
|
|
return Discourse.ScreenedIpAddress.create(b);
|
|
|
|
});
|
|
|
|
});
|
2014-11-24 11:25:48 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
rollUp: function() {
|
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses/roll_up", { type: "POST" });
|
2013-10-21 14:49:51 -04:00
|
|
|
}
|
|
|
|
});
|