discourse/app/assets/javascripts/admin/models/email_preview.js
Leo McArdle fe5264f9e9 filter by username in email digest preview
adds a user prompt on the email digest preview page to generate a preview for a particular user
also fixes some broken styling on the page
2015-10-30 18:11:38 +00:00

28 lines
718 B
JavaScript

/**
Our data model for showing a preview of an email
@class EmailPreview
@extends Discourse.Model
@namespace Discourse
@module Discourse
**/
Discourse.EmailPreview = Discourse.Model.extend({});
Discourse.EmailPreview.reopenClass({
findDigest: function(lastSeenAt, username) {
if (Em.isEmpty(lastSeenAt)) {
lastSeenAt = moment().subtract(7, 'days').format('YYYY-MM-DD');
}
if (Em.isEmpty(username)) {
username = Discourse.User.current().username;
}
return Discourse.ajax("/admin/email/preview-digest.json", {
data: { last_seen_at: lastSeenAt, username: username }
}).then(function (result) {
return Discourse.EmailPreview.create(result);
});
}
});