committed by
Joffrey JAFFEUX
parent
c617e512ad
commit
4b455e741e
@@ -293,17 +293,19 @@ const AdminUser = Discourse.User.extend({
|
||||
});
|
||||
},
|
||||
|
||||
canLockTrustLevel: function() {
|
||||
return this.get("trust_level") < 4;
|
||||
}.property("trust_level"),
|
||||
@computed("trust_level")
|
||||
canLockTrustLevel(trustLevel) {
|
||||
return trustLevel < 4;
|
||||
},
|
||||
|
||||
canSuspend: Ember.computed.not("staff"),
|
||||
|
||||
suspendDuration: function() {
|
||||
const suspended_at = moment(this.suspended_at),
|
||||
suspended_till = moment(this.suspended_till);
|
||||
return suspended_at.format("L") + " - " + suspended_till.format("L");
|
||||
}.property("suspended_till", "suspended_at"),
|
||||
@computed("suspended_till", "suspended_at")
|
||||
suspendDuration(suspendedTill, suspendedAt) {
|
||||
suspendedAt = moment(suspendedAt);
|
||||
suspendedTill = moment(suspendedTill);
|
||||
return suspendedAt.format("L") + " - " + suspendedTill.format("L");
|
||||
},
|
||||
|
||||
suspend(data) {
|
||||
return ajax(`/admin/users/${this.id}/suspend`, {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import ColorSchemeColor from "admin/models/color-scheme-color";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
init: function() {
|
||||
@@ -7,9 +8,10 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
this.startTrackingChanges();
|
||||
},
|
||||
|
||||
description: function() {
|
||||
@computed
|
||||
description() {
|
||||
return "" + this.name;
|
||||
}.property(),
|
||||
},
|
||||
|
||||
startTrackingChanges: function() {
|
||||
this.set("originals", {
|
||||
@@ -44,7 +46,8 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
return newScheme;
|
||||
},
|
||||
|
||||
changed: function() {
|
||||
@computed("name", "colors.@each.changed", "saving")
|
||||
changed() {
|
||||
if (!this.originals) return false;
|
||||
if (this.originals["name"] !== this.get("name")) return true;
|
||||
if (
|
||||
@@ -54,24 +57,23 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
}.property("name", "colors.@each.changed", "saving"),
|
||||
},
|
||||
|
||||
disableSave: function() {
|
||||
@computed("changed")
|
||||
disableSave(changed) {
|
||||
if (this.get("theme_id")) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
!this.get("changed") ||
|
||||
!changed ||
|
||||
this.get("saving") ||
|
||||
_.any(this.get("colors"), function(c) {
|
||||
return !c.get("valid");
|
||||
})
|
||||
);
|
||||
}.property("changed"),
|
||||
},
|
||||
|
||||
newRecord: function() {
|
||||
return !this.get("id");
|
||||
}.property("id"),
|
||||
newRecord: Ember.computed.not("id"),
|
||||
|
||||
save: function(opts) {
|
||||
if (this.get("is_base") || this.get("disableSave")) return;
|
||||
|
||||
@@ -76,25 +76,35 @@ const Report = Discourse.Model.extend({
|
||||
}
|
||||
},
|
||||
|
||||
todayCount: function() {
|
||||
@computed("data", "average")
|
||||
todayCount() {
|
||||
return this.valueAt(0);
|
||||
}.property("data", "average"),
|
||||
yesterdayCount: function() {
|
||||
return this.valueAt(1);
|
||||
}.property("data", "average"),
|
||||
sevenDaysAgoCount: function() {
|
||||
return this.valueAt(7);
|
||||
}.property("data", "average"),
|
||||
thirtyDaysAgoCount: function() {
|
||||
return this.valueAt(30);
|
||||
}.property("data", "average"),
|
||||
},
|
||||
|
||||
lastSevenDaysCount: function() {
|
||||
@computed("data", "average")
|
||||
yesterdayCount() {
|
||||
return this.valueAt(1);
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
sevenDaysAgoCount() {
|
||||
return this.valueAt(7);
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
thirtyDaysAgoCount() {
|
||||
return this.valueAt(30);
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
lastSevenDaysCount() {
|
||||
return this.averageCount(7, this.valueFor(1, 7));
|
||||
}.property("data", "average"),
|
||||
lastThirtyDaysCount: function() {
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
lastThirtyDaysCount() {
|
||||
return this.averageCount(30, this.valueFor(1, 30));
|
||||
}.property("data", "average"),
|
||||
},
|
||||
|
||||
averageCount(count, value) {
|
||||
return this.get("average") ? value / count : value;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
const ScreenedEmail = Discourse.Model.extend({
|
||||
actionName: function() {
|
||||
return I18n.t("admin.logs.screened_actions." + this.get("action"));
|
||||
}.property("action"),
|
||||
@computed("action")
|
||||
actionName(action) {
|
||||
return I18n.t("admin.logs.screened_actions." + action);
|
||||
},
|
||||
|
||||
clearBlock: function() {
|
||||
return ajax("/admin/logs/screened_emails/" + this.get("id"), {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
const ScreenedUrl = Discourse.Model.extend({
|
||||
actionName: function() {
|
||||
return I18n.t("admin.logs.screened_actions." + this.get("action"));
|
||||
}.property("action")
|
||||
@computed("action")
|
||||
actionName(action) {
|
||||
return I18n.t("admin.logs.screened_actions." + action);
|
||||
}
|
||||
});
|
||||
|
||||
ScreenedUrl.reopenClass({
|
||||
|
||||
@@ -11,36 +11,7 @@ export default Discourse.Model.extend({
|
||||
return Math.round((minDaysVisited * 100) / timePeriod);
|
||||
},
|
||||
|
||||
met: function() {
|
||||
return {
|
||||
days_visited: this.get("days_visited") >= this.get("min_days_visited"),
|
||||
topics_replied_to:
|
||||
this.get("num_topics_replied_to") >= this.get("min_topics_replied_to"),
|
||||
topics_viewed: this.get("topics_viewed") >= this.get("min_topics_viewed"),
|
||||
posts_read: this.get("posts_read") >= this.get("min_posts_read"),
|
||||
topics_viewed_all_time:
|
||||
this.get("topics_viewed_all_time") >=
|
||||
this.get("min_topics_viewed_all_time"),
|
||||
posts_read_all_time:
|
||||
this.get("posts_read_all_time") >= this.get("min_posts_read_all_time"),
|
||||
flagged_posts:
|
||||
this.get("num_flagged_posts") <= this.get("max_flagged_posts"),
|
||||
flagged_by_users:
|
||||
this.get("num_flagged_by_users") <= this.get("max_flagged_by_users"),
|
||||
likes_given: this.get("num_likes_given") >= this.get("min_likes_given"),
|
||||
likes_received:
|
||||
this.get("num_likes_received") >= this.get("min_likes_received"),
|
||||
likes_received_days:
|
||||
this.get("num_likes_received_days") >=
|
||||
this.get("min_likes_received_days"),
|
||||
likes_received_users:
|
||||
this.get("num_likes_received_users") >=
|
||||
this.get("min_likes_received_users"),
|
||||
level_locked: this.get("trust_level_locked"),
|
||||
silenced: this.get("penalty_counts.silenced") === 0,
|
||||
suspended: this.get("penalty_counts.suspended") === 0
|
||||
};
|
||||
}.property(
|
||||
@computed(
|
||||
"days_visited",
|
||||
"min_days_visited",
|
||||
"num_topics_replied_to",
|
||||
@@ -71,4 +42,34 @@ export default Discourse.Model.extend({
|
||||
"penalty_counts.silenced",
|
||||
"penalty_counts.suspended"
|
||||
)
|
||||
met() {
|
||||
return {
|
||||
days_visited: this.get("days_visited") >= this.get("min_days_visited"),
|
||||
topics_replied_to:
|
||||
this.get("num_topics_replied_to") >= this.get("min_topics_replied_to"),
|
||||
topics_viewed: this.get("topics_viewed") >= this.get("min_topics_viewed"),
|
||||
posts_read: this.get("posts_read") >= this.get("min_posts_read"),
|
||||
topics_viewed_all_time:
|
||||
this.get("topics_viewed_all_time") >=
|
||||
this.get("min_topics_viewed_all_time"),
|
||||
posts_read_all_time:
|
||||
this.get("posts_read_all_time") >= this.get("min_posts_read_all_time"),
|
||||
flagged_posts:
|
||||
this.get("num_flagged_posts") <= this.get("max_flagged_posts"),
|
||||
flagged_by_users:
|
||||
this.get("num_flagged_by_users") <= this.get("max_flagged_by_users"),
|
||||
likes_given: this.get("num_likes_given") >= this.get("min_likes_given"),
|
||||
likes_received:
|
||||
this.get("num_likes_received") >= this.get("min_likes_received"),
|
||||
likes_received_days:
|
||||
this.get("num_likes_received_days") >=
|
||||
this.get("min_likes_received_days"),
|
||||
likes_received_users:
|
||||
this.get("num_likes_received_users") >=
|
||||
this.get("min_likes_received_users"),
|
||||
level_locked: this.get("trust_level_locked"),
|
||||
silenced: this.get("penalty_counts.silenced") === 0,
|
||||
suspended: this.get("penalty_counts.suspended") === 0
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user