This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/models/admin_post.js
2014-07-16 21:04:55 +02:00

49 lines
1.4 KiB
JavaScript

/**
A data model for flagged/deleted posts.
@class AdminPost
@extends Discourse.Post
@namespace Discourse
@module Discourse
**/
Discourse.AdminPost = Discourse.Post.extend({
_attachCategory: function () {
var categoryId = this.get("category_id");
if (categoryId) {
this.set("category", Discourse.Category.findById(categoryId));
}
}.on("init"),
presentName: Em.computed.any('name', 'username'),
sameUser: function() {
return this.get("username") === Discourse.User.currentProp("username");
}.property("username"),
descriptionKey: function () {
if (this.get("reply_to_post_number")) {
return this.get("sameUser") ? "you_replied_to_post" : "user_replied_to_post";
} else {
return this.get("sameUser") ? "you_replied_to_topic" : "user_replied_to_topic";
}
}.property("reply_to_post_number", "sameUser"),
descriptionHtml: function () {
var descriptionKey = this.get("descriptionKey");
if (!descriptionKey) { return; }
var description = I18n.t("user_action." + descriptionKey, {
userUrl: this.get("usernameUrl"),
user: Handlebars.Utils.escapeExpression(this.get("presentName")),
postUrl: this.get("url"),
post_number: "#" + this.get("reply_to_post_number"),
topicUrl: this.get("url"),
});
return new Handlebars.SafeString(description);
}.property("descriptionKey")
});