Merge remote-tracking branch 'foodcoops/master' into feature-link_to_group_order

Conflicts:
	app/views/shared/_open_orders.html.haml
This commit is contained in:
wvengen 2013-11-25 10:11:56 +01:00
commit 1f08ee4759
58 changed files with 462 additions and 188 deletions

View file

@ -155,13 +155,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|
@ -183,4 +176,32 @@ 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 = {})
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
# 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})" : '')
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

View file

@ -2,7 +2,7 @@ module TasksHelper
def task_assignments(task)
task.assignments.map do |ass|
content_tag :span, ass.user.nick, :class => (ass.accepted? ? 'accepted' : 'unaccepted')
content_tag :span, show_user(ass.user), :class => (ass.accepted? ? 'accepted' : 'unaccepted')
end.join(", ").html_safe
end