Merge pull request #1722 from vikhyat/enable-names
enable_names site setting functionality
This commit is contained in:
commit
17110ead98
|
@ -16,11 +16,15 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({
|
|||
|
||||
saveDisabled: function() {
|
||||
if (this.get('saving')) return true;
|
||||
if (this.blank('name')) return true;
|
||||
if (Discourse.SiteSettings.enable_names && this.blank('name')) return true;
|
||||
if (this.blank('email')) return true;
|
||||
return false;
|
||||
}.property('saving', 'name', 'email'),
|
||||
|
||||
canEditName: function() {
|
||||
return Discourse.SiteSettings.enable_names;
|
||||
}.property(),
|
||||
|
||||
digestFrequencies: [{ name: I18n.t('user.email_digests.daily'), value: 1 },
|
||||
{ name: I18n.t('user.email_digests.weekly'), value: 7 },
|
||||
{ name: I18n.t('user.email_digests.bi_weekly'), value: 14 }],
|
||||
|
|
|
@ -35,6 +35,20 @@ Discourse.User = Discourse.Model.extend({
|
|||
};
|
||||
}.property('username_lower'),
|
||||
|
||||
/**
|
||||
This user's display name. Returns the name if possible, otherwise returns the
|
||||
username.
|
||||
|
||||
@property displayName
|
||||
@type {String}
|
||||
**/
|
||||
displayName: function() {
|
||||
if (Discourse.SiteSettings.enable_names && !this.blank('name')) {
|
||||
return this.get('name');
|
||||
}
|
||||
return this.get('username');
|
||||
}.property('username', 'name'),
|
||||
|
||||
/**
|
||||
This user's website.
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ Discourse.UserAction = Discourse.Model.extend({
|
|||
post_number: '#' + this.get('reply_to_post_number'),
|
||||
user1Url: this.get('userUrl'),
|
||||
user2Url: this.get('targetUserUrl'),
|
||||
another_user: this.get('target_name')
|
||||
another_user: this.get('targetDisplayName')
|
||||
}));
|
||||
|
||||
}.property('descriptionKey'),
|
||||
|
@ -99,6 +99,9 @@ Discourse.UserAction = Discourse.Model.extend({
|
|||
}.property('target_username'),
|
||||
|
||||
presentName: Em.computed.any('name', 'username'),
|
||||
targetDisplayName: Em.computed.any('target_name', 'target_username'),
|
||||
actingDisplayName: Em.computed.any('acting_name', 'acting_username'),
|
||||
|
||||
|
||||
targetUserUrl: Discourse.computed.url('target_username', '/users/%@'),
|
||||
usernameLower: function() {
|
||||
|
@ -170,7 +173,7 @@ Discourse.UserAction = Discourse.Model.extend({
|
|||
this.setProperties({
|
||||
username: this.get('acting_username'),
|
||||
avatar_template: this.get('acting_avatar_template'),
|
||||
name: this.get('acting_name')
|
||||
name: this.get('actingDisplayName')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
{{#unless showExtraInfo}}
|
||||
<div class='current-username'>
|
||||
{{#if currentUser}}
|
||||
<span class='username'><a {{bindAttr href="currentUser.path"}}>{{currentUser.name}}</a></span>
|
||||
<span class='username'><a {{bindAttr href="currentUser.path"}}>{{currentUser.displayName}}</a></span>
|
||||
{{else}}
|
||||
<button {{action showLogin}} class='btn btn-primary btn-small'>{{i18n log_in}}</button>
|
||||
{{/if}}
|
||||
|
|
|
@ -15,15 +15,17 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{i18n user.name.title}}</label>
|
||||
<div class="controls">
|
||||
{{textField value=name classNames="input-xxlarge"}}
|
||||
{{#if canEditName}}
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{i18n user.name.title}}</label>
|
||||
<div class="controls">
|
||||
{{textField value=name classNames="input-xxlarge"}}
|
||||
</div>
|
||||
<div class='instructions'>
|
||||
{{i18n user.name.instructions}}
|
||||
</div>
|
||||
</div>
|
||||
<div class='instructions'>
|
||||
{{i18n user.name.instructions}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{i18n user.email.title}}</label>
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
class BasicUserSerializer < ApplicationSerializer
|
||||
attributes :id, :username, :avatar_template
|
||||
|
||||
def include_name?
|
||||
SiteSetting.enable_names?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,6 +45,18 @@ class UserActionSerializer < ApplicationSerializer
|
|||
)
|
||||
end
|
||||
|
||||
def include_name?
|
||||
SiteSetting.enable_names?
|
||||
end
|
||||
|
||||
def include_target_name?
|
||||
include_name?
|
||||
end
|
||||
|
||||
def include_acting_name?
|
||||
include_name?
|
||||
end
|
||||
|
||||
def slug
|
||||
Slug.for(object.title)
|
||||
end
|
||||
|
|
|
@ -94,10 +94,6 @@ class UserSerializer < BasicUserSerializer
|
|||
User.gravatar_template(object.email)
|
||||
end
|
||||
|
||||
def include_name?
|
||||
SiteSetting.enable_names?
|
||||
end
|
||||
|
||||
def include_suspended?
|
||||
object.suspended?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue