Commit 67c425f7271fe22060826ebf0703e213c090d2a4
1 parent
78a58898
Exists in
master
rails3: fix email_article plugin
Showing
2 changed files
with
12 additions
and
10 deletions
Show diff stats
controllers/email_article_plugin_myprofile_controller.rb
@@ -5,7 +5,7 @@ class EmailArticlePluginMyprofileController < MyProfileController | @@ -5,7 +5,7 @@ class EmailArticlePluginMyprofileController < MyProfileController | ||
5 | def send_email | 5 | def send_email |
6 | if user.is_admin?(profile) | 6 | if user.is_admin?(profile) |
7 | article = Article.find(params[:id]) | 7 | article = Article.find(params[:id]) |
8 | - EmailArticlePluginMyprofileController::Sender.deliver_mail(article) | 8 | + EmailArticlePluginMyprofileController::Sender.content(article).deliver |
9 | render :text => "Email sent to queue" | 9 | render :text => "Email sent to queue" |
10 | else | 10 | else |
11 | render :status => :forbidden, :text => "Forbidden user" | 11 | render :status => :forbidden, :text => "Forbidden user" |
@@ -13,18 +13,20 @@ class EmailArticlePluginMyprofileController < MyProfileController | @@ -13,18 +13,20 @@ class EmailArticlePluginMyprofileController < MyProfileController | ||
13 | end | 13 | end |
14 | 14 | ||
15 | class Sender < ActionMailer::Base | 15 | class Sender < ActionMailer::Base |
16 | - def mail(article) | 16 | + def content(article) |
17 | members = article.profile.members | 17 | members = article.profile.members |
18 | emails = [] | 18 | emails = [] |
19 | members.each{ |m| | 19 | members.each{ |m| |
20 | emails.push(m.user.email) | 20 | emails.push(m.user.email) |
21 | } | 21 | } |
22 | - content_type 'text/html' | ||
23 | - recipients emails | ||
24 | - from "#{article.author.user.name} <#{article.author.user.email}>" | ||
25 | - reply_to article.author.user.email | ||
26 | - subject "[Artigo] " + article.title | ||
27 | - body set_absolute_path(article.body, article.environment) | 22 | + mail( |
23 | + content_type: 'text/html', | ||
24 | + to: emails, | ||
25 | + from: "#{article.author.user.name} <#{article.author.user.email}>", | ||
26 | + reply_to: article.author.user.email, | ||
27 | + subject: "[Artigo] " + article.title, | ||
28 | + body: set_absolute_path(article.body, article.environment) | ||
29 | + ) | ||
28 | end | 30 | end |
29 | 31 | ||
30 | def set_absolute_path(body, environment) | 32 | def set_absolute_path(body, environment) |
@@ -42,4 +44,4 @@ class EmailArticlePluginMyprofileController < MyProfileController | @@ -42,4 +44,4 @@ class EmailArticlePluginMyprofileController < MyProfileController | ||
42 | end | 44 | end |
43 | end | 45 | end |
44 | end | 46 | end |
45 | -end | ||
46 | \ No newline at end of file | 47 | \ No newline at end of file |
48 | +end |
lib/email_article_plugin.rb
@@ -13,7 +13,7 @@ class EmailArticlePlugin < Noosfero::Plugin | @@ -13,7 +13,7 @@ class EmailArticlePlugin < Noosfero::Plugin | ||
13 | htmlclass = _("button with-text icon-menu-mail") | 13 | htmlclass = _("button with-text icon-menu-mail") |
14 | title = _("Email article to all community members") | 14 | title = _("Email article to all community members") |
15 | 15 | ||
16 | - lambda { | 16 | + proc { |
17 | if !profile.blank? and !user.blank? and user.is_admin?(profile) and @page.kind_of?(TextArticle) | 17 | if !profile.blank? and !user.blank? and user.is_admin?(profile) and @page.kind_of?(TextArticle) |
18 | link_to_remote( | 18 | link_to_remote( |
19 | label, | 19 | label, |