Commit 5a2656838af2b75db0b96c101513ae33964d5959
1 parent
a7264f26
Exists in
master
and in
20 other branches
rails4: use Noosfero::Mailer to set required default_url_options
Showing
21 changed files
with
67 additions
and
36 deletions
Show diff stats
app/mailers/comment_notifier.rb
1 | -class CommentNotifier < ActionMailer::Base | |
1 | +class CommentNotifier < Noosfero::Mailer | |
2 | + | |
2 | 3 | def notification(comment) |
3 | 4 | profile = comment.article.profile |
5 | + self.environment = profile.environment | |
4 | 6 | @recipient = profile.nickname || profile.name |
5 | 7 | @sender = comment.author_name |
6 | 8 | @sender_link = comment.author_link |
... | ... | @@ -8,7 +10,6 @@ class CommentNotifier < ActionMailer::Base |
8 | 10 | @comment_url = comment.url |
9 | 11 | @comment_title = comment.title |
10 | 12 | @comment_body = comment.body |
11 | - @environment = profile.environment.name | |
12 | 13 | @url = profile.environment.top_url |
13 | 14 | |
14 | 15 | mail( |
... | ... | @@ -20,6 +21,8 @@ class CommentNotifier < ActionMailer::Base |
20 | 21 | |
21 | 22 | def mail_to_followers(comment, emails) |
22 | 23 | profile = comment.article.profile |
24 | + self.environment = profile.environment | |
25 | + | |
23 | 26 | @recipient = profile.nickname || profile.name |
24 | 27 | @sender = comment.author_name |
25 | 28 | @sender_link = comment.author_link |
... | ... | @@ -28,7 +31,6 @@ class CommentNotifier < ActionMailer::Base |
28 | 31 | @unsubscribe_url = comment.article.view_url.merge({:unfollow => true}) |
29 | 32 | @comment_title = comment.title |
30 | 33 | @comment_body = comment.body |
31 | - @environment = profile.environment.name | |
32 | 34 | @url = profile.environment.top_url |
33 | 35 | |
34 | 36 | mail( | ... | ... |
app/mailers/contact.rb
... | ... | @@ -30,14 +30,16 @@ class Contact |
30 | 30 | Contact::Sender.notification(self).deliver |
31 | 31 | end |
32 | 32 | |
33 | - class Sender < ActionMailer::Base | |
33 | + class Sender < Noosfero::Mailer | |
34 | + | |
34 | 35 | def notification(contact) |
36 | + self.environment = contact.dest.environment | |
37 | + | |
35 | 38 | @name = contact.name |
36 | 39 | @email = contact.email |
37 | 40 | @city = contact.city |
38 | 41 | @state = contact.state |
39 | 42 | @message = contact.message |
40 | - @environment = contact.dest.environment.name | |
41 | 43 | @url = url_for(:host => contact.dest.environment.default_hostname, :controller => 'home') |
42 | 44 | @target = contact.dest.name |
43 | 45 | ... | ... |
app/mailers/mailing.rb
... | ... | @@ -48,7 +48,8 @@ class Mailing < ActiveRecord::Base |
48 | 48 | end |
49 | 49 | end |
50 | 50 | |
51 | - class Sender < ActionMailer::Base | |
51 | + class Sender < Noosfero::Mailer | |
52 | + | |
52 | 53 | def notification(mailing, recipient) |
53 | 54 | @message = mailing.body |
54 | 55 | @signature_message = mailing.signature_message | ... | ... |
app/mailers/pending_task_notifier.rb
1 | -class PendingTaskNotifier < ActionMailer::Base | |
1 | +class PendingTaskNotifier < Noosfero::Mailer | |
2 | 2 | |
3 | 3 | def notification(person) |
4 | + self.environment = person.environment | |
5 | + | |
4 | 6 | @person = person |
5 | 7 | @tasks = person.tasks.pending |
6 | 8 | @organizations_with_pending_tasks = person.organizations_with_pending_tasks |
7 | - @environment = person.environment.name | |
8 | 9 | @url = url_for(:host => person.environment.default_hostname, :controller => 'home') |
9 | 10 | @default_hostname = person.environment.default_hostname |
10 | 11 | @url_for_pending_tasks = url_for(:host => person.environment.default_hostname, :controller => 'tasks', :profile => person.identifier) | ... | ... |
app/mailers/scrap_notifier.rb
1 | -class ScrapNotifier < ActionMailer::Base | |
1 | +class ScrapNotifier < Noosfero::Mailer | |
2 | + | |
2 | 3 | def notification(scrap) |
3 | 4 | sender, receiver = scrap.sender, scrap.receiver |
5 | + self.environment = sender.environment | |
6 | + | |
4 | 7 | @recipient = receiver.name |
5 | 8 | @sender = sender.name |
6 | 9 | @sender_link = sender.url |
7 | 10 | @scrap_content = scrap.content |
8 | 11 | @wall_url = scrap.scrap_wall_url |
9 | - @environment = sender.environment.name | |
10 | 12 | @url = sender.environment.top_url |
11 | 13 | mail( |
12 | 14 | to: receiver.email, | ... | ... |
app/mailers/task_mailer.rb
1 | -class TaskMailer < ActionMailer::Base | |
1 | +class TaskMailer < Noosfero::Mailer | |
2 | 2 | |
3 | 3 | def target_notification(task, message) |
4 | + self.environment = task.environment | |
5 | + | |
4 | 6 | @message = extract_message(message) |
5 | 7 | @target = task.target.name |
6 | - @environment = task.environment.name | |
7 | 8 | @url = generate_environment_url(task, :controller => 'home') |
8 | 9 | url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.tasks_url.merge(:script_name => Noosfero.root('/'))) |
9 | 10 | @tasks_url = url_for_tasks_list |
... | ... | @@ -16,6 +17,8 @@ class TaskMailer < ActionMailer::Base |
16 | 17 | end |
17 | 18 | |
18 | 19 | def invitation_notification(task) |
20 | + self.environment = task.requestor.environment | |
21 | + | |
19 | 22 | msg = task.expanded_message |
20 | 23 | @message = msg.gsub /<url>/, generate_environment_url(task, :controller => 'account', :action => 'signup', :invitation_code => task.code) |
21 | 24 | |
... | ... | @@ -27,11 +30,12 @@ class TaskMailer < ActionMailer::Base |
27 | 30 | end |
28 | 31 | |
29 | 32 | def generic_message(name, task) |
33 | + self.environment = task.requestor.environment | |
34 | + | |
30 | 35 | return if !task.respond_to?("#{name}_message") |
31 | 36 | |
32 | 37 | @message = extract_message(task.send("#{name}_message")) |
33 | 38 | @requestor = task.requestor.name |
34 | - @environment = task.requestor.environment.name | |
35 | 39 | @url = url_for(:host => task.requestor.environment.default_hostname, :controller => 'home') |
36 | 40 | |
37 | 41 | mail( | ... | ... |
app/mailers/user_mailer.rb
1 | -class UserMailer < ActionMailer::Base | |
1 | +class UserMailer < Noosfero::Mailer | |
2 | + | |
2 | 3 | def activation_email_notify(user) |
4 | + self.environment = user.environment | |
5 | + | |
3 | 6 | user_email = "#{user.login}@#{user.email_domain}" |
4 | 7 | @name = user.name |
5 | 8 | @email = user_email |
6 | 9 | @webmail = MailConf.webmail_url(user.login, user.email_domain) |
7 | - @environment = user.environment.name | |
8 | 10 | @url = url_for(:host => user.environment.default_hostname, :controller => 'home') |
9 | 11 | |
10 | 12 | mail( |
... | ... | @@ -15,9 +17,10 @@ class UserMailer < ActionMailer::Base |
15 | 17 | end |
16 | 18 | |
17 | 19 | def activation_code(user) |
20 | + self.environment = user.environment | |
21 | + | |
18 | 22 | @recipient = user.name |
19 | 23 | @activation_code = user.activation_code |
20 | - @environment = user.environment.name | |
21 | 24 | @url = user.environment.top_url |
22 | 25 | @redirection = (true if user.return_to) |
23 | 26 | @join = (user.community_to_join if user.community_to_join) |
... | ... | @@ -30,6 +33,8 @@ class UserMailer < ActionMailer::Base |
30 | 33 | end |
31 | 34 | |
32 | 35 | def signup_welcome_email(user) |
36 | + self.environment = user.environment | |
37 | + | |
33 | 38 | @body = user.environment.signup_welcome_text_body.gsub('{user_name}', user.name) |
34 | 39 | email_subject = user.environment.signup_welcome_text_subject |
35 | 40 | mail( |
... | ... | @@ -42,8 +47,9 @@ class UserMailer < ActionMailer::Base |
42 | 47 | end |
43 | 48 | |
44 | 49 | def profiles_suggestions_email(user) |
50 | + self.environment = user.environment | |
51 | + | |
45 | 52 | @recipient = user.name |
46 | - @environment = user.environment.name | |
47 | 53 | @url = user.environment.top_url |
48 | 54 | @people_suggestions_url = user.people_suggestions_url |
49 | 55 | @people_suggestions = user.suggested_people.sample(3) | ... | ... |
app/views/comment_notifier/mail_to_followers.html.erb
app/views/comment_notifier/notification.text.erb
app/views/contact/sender/notification.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | </head> |
6 | 6 | <body> |
7 | 7 | <p><%= _('This message was sent by %{sender} to %{target} on %{environment}.') % |
8 | - {:sender => @name, :target => @target, :environment => @environment} %></p> | |
8 | + {:sender => @name, :target => @target, :environment => @environment.name} %></p> | |
9 | 9 | <%= _('Information about the user who sent this message:')%> |
10 | 10 | <ul> |
11 | 11 | <li><%= content_tag('b', _('Name')+': ') + @name.to_s %></li> |
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | |
21 | 21 | --<br/> |
22 | 22 | <%= _('Greetings,') %><br/> |
23 | - <%= _('%s team.') % @environment %><br/> | |
23 | + <%= _('%s team.') % @environment.name %><br/> | |
24 | 24 | <%= @url %> |
25 | 25 | </body> |
26 | 26 | </html> | ... | ... |
app/views/pending_task_notifier/notification.text.erb
app/views/person_notifier/mailer/content_summary.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <div style="display: table; background-color: white; margin: 26px 0;"> |
4 | 4 | <div style="padding: 25px 20px 20px 20px;text-align: left;"> |
5 | 5 | <%= link_to @url, :style => "text-decoration: none;" do %> |
6 | - <span style="font-weight:bold;font-size: 28px;margin: 0;color: white;background-color: #AAAAAA;padding: 5px;"><%= @environment %></span> | |
6 | + <span style="font-weight:bold;font-size: 28px;margin: 0;color: white;background-color: #AAAAAA;padding: 5px;"><%= @environment.name %></span> | |
7 | 7 | <% end %> |
8 | 8 | <span style="font-weight:bold;color: #333;font-size:19px;margin-left: 8px;"><%= _("%s's Notifications") % @profile.name %></h3> |
9 | 9 | </div> |
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | |
35 | 35 | <div style="color:#444444;font-size:11px;margin-bottom: 20px;"> |
36 | 36 | <p style="margin:0"><%= _("Greetings,") %></p> |
37 | - <p style="margin:0"><%= _('%s team.') % @environment %></p> | |
37 | + <p style="margin:0"><%= _('%s team.') % @environment.name %></p> | |
38 | 38 | <p style="margin:0"><%= link_to @url, url_for(@url) %></p> |
39 | 39 | </div> |
40 | 40 | </div> | ... | ... |
app/views/scrap_notifier/notification.text.erb
app/views/task_mailer/generic_message.text.erb
app/views/task_mailer/target_notification.text.erb
app/views/user/mailer/activation_code.html.erb
1 | 1 | <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> |
2 | 2 | |
3 | -<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code, :redirection => @redirection, :join => @join) }) %> | |
3 | +<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment.name, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code, :redirection => @redirection, :join => @join) }) %> | |
4 | 4 | |
5 | 5 | <%= _("Greetings,") %> |
6 | 6 | |
7 | 7 | -- |
8 | -<%= _('%s team.') % @environment %> | |
8 | +<%= _('%s team.') % @environment.name %> | |
9 | 9 | <%= url_for @url %> | ... | ... |
app/views/user_mailer/activation_code.text.erb
1 | 1 | <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> |
2 | 2 | |
3 | -<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code, :redirection => @redirection, :join => @join) }) %> | |
3 | +<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment.name, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code, :redirection => @redirection, :join => @join) }) %> | |
4 | 4 | |
5 | 5 | <%= _("Greetings,") %> |
6 | 6 | |
7 | 7 | -- |
8 | -<%= _('%s team.') % @environment %> | |
8 | +<%= _('%s team.') % @environment.name %> | |
9 | 9 | <%= url_for @url %> | ... | ... |
app/views/user_mailer/activation_email_notify.text.erb
app/views/user_mailer/profiles_suggestions_email.html.erb
plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb
... | ... | @@ -28,9 +28,11 @@ class WorkAssignmentPlugin::EmailContact |
28 | 28 | WorkAssignmentPlugin::EmailContact::EmailSender.notification(self).deliver |
29 | 29 | end |
30 | 30 | |
31 | - class EmailSender < ActionMailer::Base | |
31 | + class EmailSender < Noosfero::Mailer | |
32 | 32 | |
33 | 33 | def notification(email_contact) |
34 | + self.environment = email_contact.sender.environment | |
35 | + | |
34 | 36 | name = email_contact.sender.name |
35 | 37 | email = email_contact.sender.email |
36 | 38 | message = email_contact.message | ... | ... |