Move some display logic out of model, upgrade old code patterns

This commit is contained in:
Robin Ward
2018-05-25 11:33:01 -04:00
parent fdce116838
commit c658fb6e31
4 changed files with 42 additions and 42 deletions

View File

@ -50,6 +50,36 @@ export default Ember.Controller.extend(CanCheckEmails, {
return userPath(`${username}/preferences`);
},
@computed('model.can_delete_all_posts', 'model.staff', 'model.post_count')
deleteAllPostsExplanation(canDeleteAllPosts, staff, postCount) {
if (canDeleteAllPosts) {
return null;
}
if (staff) {
return I18n.t('admin.user.delete_posts_forbidden_because_staff');
}
if (postCount > this.siteSettings.delete_all_posts_max) {
return I18n.t('admin.user.cant_delete_all_too_many_posts', {count: this.siteSettings.delete_all_posts_max});
} else {
return I18n.t('admin.user.cant_delete_all_posts', {count: this.siteSettings.delete_user_max_post_age});
}
},
@computed('model.canBeDeleted', 'model.staff')
deleteExplanation(canBeDeleted, staff) {
if (canBeDeleted) {
return null;
}
if (staff) {
return I18n.t('admin.user.delete_forbidden_because_staff');
} else {
return I18n.t('admin.user.delete_forbidden', {count: this.siteSettings.delete_user_max_post_age});
}
},
actions: {
impersonate() { return this.get("model").impersonate(); },