Commit 91998f5b804e2c309bb666cd12f86fb75618b82b
1 parent
302e1cd4
Exists in
staging
and in
42 other branches
ActionItem1165: sending e-mail do the right place
Showing
3 changed files
with
12 additions
and
4 deletions
Show diff stats
app/models/person.rb
@@ -194,9 +194,13 @@ class Person < Profile | @@ -194,9 +194,13 @@ class Person < Profile | ||
194 | 194 | ||
195 | has_and_belongs_to_many :favorite_enterprises, :class_name => 'Enterprise', :join_table => 'favorite_enteprises_people' | 195 | has_and_belongs_to_many :favorite_enterprises, :class_name => 'Enterprise', :join_table => 'favorite_enteprises_people' |
196 | 196 | ||
197 | + def email_domain | ||
198 | + user && user.email_domain || environment.default_hostname(true) | ||
199 | + end | ||
200 | + | ||
197 | def email_addresses | 201 | def email_addresses |
198 | # TODO for now, only one e-mail address | 202 | # TODO for now, only one e-mail address |
199 | - ['%s@%s' % [self.identifier, (self.preferred_domain ? self.preferred_domain.name : self.environment.default_hostname(true)) ] ] | 203 | + ['%s@%s' % [self.identifier, self.email_domain] ] |
200 | end | 204 | end |
201 | 205 | ||
202 | def display_info_to?(user) | 206 | def display_info_to?(user) |
app/models/user.rb
@@ -50,15 +50,19 @@ class User < ActiveRecord::Base | @@ -50,15 +50,19 @@ class User < ActiveRecord::Base | ||
50 | end | 50 | end |
51 | end | 51 | end |
52 | 52 | ||
53 | + def email_domain | ||
54 | + self.person.preferred_domain && self.person.preferred_domain.name || self.environment.default_hostname(true) | ||
55 | + end | ||
56 | + | ||
53 | class Mailer < ActionMailer::Base | 57 | class Mailer < ActionMailer::Base |
54 | def activation_email_notify(user) | 58 | def activation_email_notify(user) |
55 | - user_email = "#{user.login}@#{user.environment.default_hostname(true)}" | 59 | + user_email = "#{user.login}@#{user.email_domain}" |
56 | recipients user_email | 60 | recipients user_email |
57 | from "#{user.environment.name} <#{user.environment.contact_email}>" | 61 | from "#{user.environment.name} <#{user.environment.contact_email}>" |
58 | subject _("[%{environment}] Welcome to %{environment} mail!") % { :environment => user.environment.name } | 62 | subject _("[%{environment}] Welcome to %{environment} mail!") % { :environment => user.environment.name } |
59 | body :name => user.name, | 63 | body :name => user.name, |
60 | :email => user_email, | 64 | :email => user_email, |
61 | - :webmail => MailConf.webmail_url(user.login, user.person.preferred_domain && user.person.preferred_domain.name || user.environment.default_hostname(true)), | 65 | + :webmail => MailConf.webmail_url(user.login, user.email_domain), |
62 | :environment => user.environment.name, | 66 | :environment => user.environment.name, |
63 | :url => url_for(:host => user.environment.default_hostname, :controller => 'home') | 67 | :url => url_for(:host => user.environment.default_hostname, :controller => 'home') |
64 | end | 68 | end |
app/views/shared/user_menu.rhtml
@@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
31 | 31 | ||
32 | <% if MailConf.enabled? && current_user.enable_email %> | 32 | <% if MailConf.enabled? && current_user.enable_email %> |
33 | <li> | 33 | <li> |
34 | - <%= link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url(user.identifier, user.preferred_domain && user.preferred_domain.name || user.environment.default_hostname(true)) %> | 34 | + <%= link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url(user.identifier, current_user.email_domain) %> |
35 | </li> | 35 | </li> |
36 | <% end %> | 36 | <% end %> |
37 | 37 |