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() {
|
saveDisabled: function() {
|
||||||
if (this.get('saving')) return true;
|
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;
|
if (this.blank('email')) return true;
|
||||||
return false;
|
return false;
|
||||||
}.property('saving', 'name', 'email'),
|
}.property('saving', 'name', 'email'),
|
||||||
|
|
||||||
|
canEditName: function() {
|
||||||
|
return Discourse.SiteSettings.enable_names;
|
||||||
|
}.property(),
|
||||||
|
|
||||||
digestFrequencies: [{ name: I18n.t('user.email_digests.daily'), value: 1 },
|
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.weekly'), value: 7 },
|
||||||
{ name: I18n.t('user.email_digests.bi_weekly'), value: 14 }],
|
{ name: I18n.t('user.email_digests.bi_weekly'), value: 14 }],
|
||||||
|
|
|
@ -35,6 +35,20 @@ Discourse.User = Discourse.Model.extend({
|
||||||
};
|
};
|
||||||
}.property('username_lower'),
|
}.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.
|
This user's website.
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ Discourse.UserAction = Discourse.Model.extend({
|
||||||
post_number: '#' + this.get('reply_to_post_number'),
|
post_number: '#' + this.get('reply_to_post_number'),
|
||||||
user1Url: this.get('userUrl'),
|
user1Url: this.get('userUrl'),
|
||||||
user2Url: this.get('targetUserUrl'),
|
user2Url: this.get('targetUserUrl'),
|
||||||
another_user: this.get('target_name')
|
another_user: this.get('targetDisplayName')
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}.property('descriptionKey'),
|
}.property('descriptionKey'),
|
||||||
|
@ -99,6 +99,9 @@ Discourse.UserAction = Discourse.Model.extend({
|
||||||
}.property('target_username'),
|
}.property('target_username'),
|
||||||
|
|
||||||
presentName: Em.computed.any('name', '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/%@'),
|
targetUserUrl: Discourse.computed.url('target_username', '/users/%@'),
|
||||||
usernameLower: function() {
|
usernameLower: function() {
|
||||||
|
@ -170,7 +173,7 @@ Discourse.UserAction = Discourse.Model.extend({
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
username: this.get('acting_username'),
|
username: this.get('acting_username'),
|
||||||
avatar_template: this.get('acting_avatar_template'),
|
avatar_template: this.get('acting_avatar_template'),
|
||||||
name: this.get('acting_name')
|
name: this.get('actingDisplayName')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
{{#unless showExtraInfo}}
|
{{#unless showExtraInfo}}
|
||||||
<div class='current-username'>
|
<div class='current-username'>
|
||||||
{{#if currentUser}}
|
{{#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}}
|
{{else}}
|
||||||
<button {{action showLogin}} class='btn btn-primary btn-small'>{{i18n log_in}}</button>
|
<button {{action showLogin}} class='btn btn-primary btn-small'>{{i18n log_in}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -15,15 +15,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
{{#if canEditName}}
|
||||||
<label class="control-label">{{i18n user.name.title}}</label>
|
<div class="control-group">
|
||||||
<div class="controls">
|
<label class="control-label">{{i18n user.name.title}}</label>
|
||||||
{{textField value=name classNames="input-xxlarge"}}
|
<div class="controls">
|
||||||
|
{{textField value=name classNames="input-xxlarge"}}
|
||||||
|
</div>
|
||||||
|
<div class='instructions'>
|
||||||
|
{{i18n user.name.instructions}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='instructions'>
|
{{/if}}
|
||||||
{{i18n user.name.instructions}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{i18n user.email.title}}</label>
|
<label class="control-label">{{i18n user.email.title}}</label>
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
class BasicUserSerializer < ApplicationSerializer
|
class BasicUserSerializer < ApplicationSerializer
|
||||||
attributes :id, :username, :avatar_template
|
attributes :id, :username, :avatar_template
|
||||||
|
|
||||||
|
def include_name?
|
||||||
|
SiteSetting.enable_names?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,6 +45,18 @@ class UserActionSerializer < ApplicationSerializer
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def include_name?
|
||||||
|
SiteSetting.enable_names?
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_target_name?
|
||||||
|
include_name?
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_acting_name?
|
||||||
|
include_name?
|
||||||
|
end
|
||||||
|
|
||||||
def slug
|
def slug
|
||||||
Slug.for(object.title)
|
Slug.for(object.title)
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,10 +94,6 @@ class UserSerializer < BasicUserSerializer
|
||||||
User.gravatar_template(object.email)
|
User.gravatar_template(object.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_name?
|
|
||||||
SiteSetting.enable_names?
|
|
||||||
end
|
|
||||||
|
|
||||||
def include_suspended?
|
def include_suspended?
|
||||||
object.suspended?
|
object.suspended?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue