discourse/app/assets/javascripts/admin/models/email_log.js
2014-02-15 01:17:13 +01:00

36 lines
765 B
JavaScript

/**
Our data model for representing an email log.
@class EmailLog
@extends Discourse.Model
@namespace Discourse
@module Discourse
**/
Discourse.EmailLog = Discourse.Model.extend({});
Discourse.EmailLog.reopenClass({
create: function(attrs) {
attrs = attrs || {};
if (attrs.user) {
attrs.user = Discourse.AdminUser.create(attrs.user);
}
return this._super(attrs);
},
findAll: function(filter) {
filter = filter || {};
var status = filter.status || "all";
filter = _.omit(filter, "status");
return Discourse.ajax("/admin/email/" + status + ".json", { data: filter }).then(function(logs) {
return _.map(logs, function (log) {
return Discourse.EmailLog.create(log);
});
});
}
});