user display changes in model and mailer
This commit is contained in:
parent
f6c2fd9a9d
commit
ea3db22306
4 changed files with 23 additions and 9 deletions
|
|
@ -49,7 +49,7 @@ class Message < ActiveRecord::Base
|
|||
@reply_to = Message.find(message_id)
|
||||
add_recipients([@reply_to.sender])
|
||||
self.subject = I18n.t('messages.model.reply_subject', :subject => @reply_to.subject)
|
||||
self.body = I18n.t('messages.model.reply_header', :user => @reply_to.sender.nick, :when => I18n.l(@reply_to.created_at, :format => :short)) + "\n"
|
||||
self.body = I18n.t('messages.model.reply_header', :user => @reply_to.sender.display, :when => I18n.l(@reply_to.created_at, :format => :short)) + "\n"
|
||||
@reply_to.body.each_line{ |l| self.body += I18n.t('messages.model.reply_indent', :line => l) }
|
||||
end
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def sender_name
|
||||
system_message? ? I18n.t('layouts.foodsoft') : sender.nick rescue "??"
|
||||
system_message? ? I18n.t('layouts.foodsoft') : sender.display rescue "?"
|
||||
end
|
||||
|
||||
def recipients
|
||||
|
|
@ -77,7 +77,7 @@ class Message < ActiveRecord::Base
|
|||
begin
|
||||
Mailer.foodsoft_message(self, user).deliver
|
||||
rescue
|
||||
Rails.logger.warn "Deliver failed for #{user.nick}: #{user.email}"
|
||||
Rails.logger.warn "Deliver failed for user \##{user.id}: #{user.email}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Ordergroup < Group
|
|||
"#{contact_phone} (#{contact_person})"
|
||||
end
|
||||
def non_members
|
||||
User.all(:order => 'nick').reject { |u| (users.include?(u) || u.ordergroup) }
|
||||
User.natural_order.all.reject { |u| (users.include?(u) || u.ordergroup) }
|
||||
end
|
||||
|
||||
def value_of_open_orders(exclude = nil)
|
||||
|
|
@ -102,7 +102,7 @@ class Ordergroup < Group
|
|||
# Make sure, that a user can only be in one ordergroup
|
||||
def uniqueness_of_members
|
||||
users.each do |user|
|
||||
errors.add :user_tokens, I18n.t('ordergroups.model.error_single_group', :user => user.nick) if user.groups.where(:type => 'Ordergroup').size > 1
|
||||
errors.add :user_tokens, I18n.t('ordergroups.model.error_single_group', :user => user.display) if user.groups.where(:type => 'Ordergroup').size > 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -158,8 +158,17 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# 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 : "#{first_name} #{last_name}"
|
||||
end
|
||||
|
||||
def token_attributes
|
||||
{:id => id, :name => "#{nick} (#{ordergroup.try(:name)})"}
|
||||
# would be sensible to match ApplicationController#show_user
|
||||
# this should not be part of the model anyway
|
||||
{:id => id, :name => "#{display} (#{ordergroup.try(:name)})"}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue