display admin/mod status on user page

This commit is contained in:
Sam 2013-05-02 17:40:44 +10:00
parent 5ec52bd2e9
commit cb9a89940a
5 changed files with 28 additions and 6 deletions

View file

@ -42,6 +42,19 @@ Discourse.User = Discourse.Model.extend({
return this.present('website');
}.property('website'),
statusIcon: function() {
var desc;
if(this.get('admin')) {
desc = Em.String.i18n('user.admin', {user: this.get("name")});
return '<i class="icon icon-trophy" title="' + desc + '" alt="' + desc + '"></i>';
}
if(this.get('moderator')){
desc = Em.String.i18n('user.moderator', {user: this.get("name")});
return '<i class="icon icon-magic" title="' + desc + '" alt="' + desc + '"></i>';
}
return null;
}.property('admin','moderator'),
/**
Path to this user.

View file

@ -1,14 +1,14 @@
{{#unless content.loading}}
{{#unless model.loading}}
<div class="user-heading">
<div class="container">
<div class="full-width" id='user-menu'>
<h1>{{content.name}}<span>{{unbound content.username}}</span></h1>
<h1>{{model.name}}<span>{{unbound model.username}}{{{unbound model.statusIcon}}}</span></h1>
{{#if viewingSelf}}
<button {{action "logout" target="Discourse"}} class='btn'>{{i18n user.log_out}}</button>
{{/if}}
{{#if Discourse.currentUser.staff}}
<a href="{{unbound content.adminPath}}" class='btn'><i class="icon-wrench"></i>&nbsp;{{i18n admin.user.show_admin_profile}}</a>
<a href="{{unbound model.adminPath}}" class='btn'><i class="icon-wrench"></i>&nbsp;{{i18n admin.user.show_admin_profile}}</a>
{{/if}}
<ul class="nav nav-pills">
<li>
@ -22,7 +22,7 @@
<li>
{{#linkTo 'user.invited'}}{{i18n user.invited.title}}{{/linkTo}}
</li>
{{#if content.can_edit}}
{{#if model.can_edit}}
<li>
{{#linkTo 'preferences'}}{{i18n user.preferences}}{{/linkTo}}
</li>
@ -37,7 +37,7 @@
<div class="container">
<div class='user-info clearfix'>
<div class='about-me'>
{{{content.bio_excerpt}}}
{{{model.bio_excerpt}}}
</div>
</div>
</div>

View file

@ -155,6 +155,10 @@
font-weight: lighter;
position: relative;
top: -4px;
.icon {
margin-left: 5px;
font-size: 14px;
}
}
}

View file

@ -14,7 +14,9 @@ class UserSerializer < BasicUserSerializer
:can_send_private_message_to_user,
:bio_excerpt,
:invited_by,
:trust_level
:trust_level,
:moderator,
:admin
def self.private_attributes(*attrs)

View file

@ -97,6 +97,9 @@ en:
external_links_in_new_tab: "Open all external links in a new tab"
enable_quoting: "Enable quote reply for highlighted text"
moderator: "{{user}} is a moderator"
admin: "{{user}} is an admin"
change_password:
action: "change"
success: "(email sent)"