fallback for when nick is nil
This commit is contained in:
parent
e968919cce
commit
9ba425aafa
6 changed files with 12 additions and 6 deletions
|
@ -170,7 +170,8 @@ module ApplicationHelper
|
|||
elsif options[:full]
|
||||
"#{user.nick} (#{user.first_name} #{user.last_name})"
|
||||
else
|
||||
user.nick
|
||||
# when use_nick was changed from false to true, users may exist without nick
|
||||
user.nick.nil? ? I18n.t('helpers.application.nick_fallback') : user.nick
|
||||
end
|
||||
else
|
||||
"#{user.first_name} #{user.last_name}" + (options[:unique] ? " (\##{user.id})" : '')
|
||||
|
|
|
@ -161,8 +161,12 @@ class User < ActiveRecord::Base
|
|||
# XXX this is view-related; need to move out things like token_attributes
|
||||
# then this can be removed
|
||||
def display
|
||||
# would be sensible to match ApplicationController#show_user
|
||||
FoodsoftConfig[:use_nick] ? nick : name
|
||||
# would be sensible to match ApplicationHelper#show_user
|
||||
if FoodsoftConfig[:use_nick]
|
||||
nick.nil? ? I18n.t('helpers.application.nick_fallback') : nick
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
def token_attributes
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
%th= t '.created_at'
|
||||
- for user in @users
|
||||
%tr{:class => cycle('even','odd', :name => 'users')}
|
||||
%td= link_to show_user(user, full: true), [:admin, user]
|
||||
%td= link_to show_user(user), [:admin, user]
|
||||
- if FoodsoftConfig[:use_nick]
|
||||
%td= link_to user.name
|
||||
%td= format_date(user.created_on)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
%tbody
|
||||
- for user in @users
|
||||
%tr
|
||||
%td= link_to show_user(user, full: true), [:admin, user]
|
||||
%td= link_to show_user(user), [:admin, user]
|
||||
- if FoodsoftConfig[:use_nick]
|
||||
%td= user.name
|
||||
%td= user.email
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
- for user in @users
|
||||
%tr
|
||||
- if FoodsoftConfig[:use_nick]
|
||||
%td= user.nick
|
||||
%td= show_user user
|
||||
%td= user.name if @current_user.role_admin? || user.settings.profile["name_is_public"] || !FoodsoftConfig[:use_nick]
|
||||
%td= user.email if @current_user.role_admin? || user.settings.profile["email_is_public"]
|
||||
%td= user.phone if @current_user.role_admin? || user.settings.profile["phone_is_public"]
|
||||
|
|
|
@ -864,6 +864,7 @@ en:
|
|||
helpers:
|
||||
application:
|
||||
edit_user: Edit user
|
||||
nick_fallback: (empty username)
|
||||
role_admin: Admin
|
||||
role_article_meta: Articles
|
||||
role_finance: Finance
|
||||
|
|
Loading…
Reference in a new issue