start of making nickname optional
This commit is contained in:
parent
a77c3b59b1
commit
e4f0a1e3ed
33 changed files with 92 additions and 48 deletions
|
|
@ -139,13 +139,6 @@ module ApplicationHelper
|
|||
:target => "_blank"
|
||||
end
|
||||
|
||||
# offers a link for writing message to user
|
||||
# checks for nil (useful for relations)
|
||||
def link_to_user_message_if_valid(user)
|
||||
user.nil? ? '??' : link_to(user.nick, new_message_path('message[mail_to]' => user.id),
|
||||
:title => I18n.t('helpers.application.write_message'))
|
||||
end
|
||||
|
||||
def bootstrap_flash
|
||||
flash_messages = []
|
||||
flash.each do |type, message|
|
||||
|
|
@ -167,4 +160,31 @@ module ApplicationHelper
|
|||
render :partial => 'shared/base_errors', :locals => {:error_messages => messages}
|
||||
end
|
||||
|
||||
# show a user, depending on settings
|
||||
def show_user(user=@current_user, options = {})#full: false, markup: false, unique: false)
|
||||
if user.nil?
|
||||
"?"
|
||||
elsif FoodsoftConfig[:use_nick]
|
||||
if options[:full] and options[:markup]
|
||||
raw "<b>#{h user.nick}</b> (#{h user.first_name} #{h user.last_name})"
|
||||
elsif options[:full]
|
||||
"#{user.nick} (#{user.first_name} #{user.last_name})"
|
||||
else
|
||||
user.nick
|
||||
end
|
||||
else
|
||||
"#{user.first_name} #{user.last_name}" + (options[:unique] ? " (\##{user.id})" : '')
|
||||
end
|
||||
end
|
||||
|
||||
# render user presentation linking to default action (write message)
|
||||
def show_user_link(user=@current_user)
|
||||
if user.nil?
|
||||
show_user user
|
||||
else
|
||||
link_to show_user(user), new_message_path('message[mail_to]' => user.id),
|
||||
:title => I18n.t('helpers.application.write_message')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue