From 67c425f7271fe22060826ebf0703e213c090d2a4 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 7 Jul 2014 11:01:06 -0300 Subject: [PATCH] rails3: fix email_article plugin --- controllers/email_article_plugin_myprofile_controller.rb | 20 +++++++++++--------- lib/email_article_plugin.rb | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/controllers/email_article_plugin_myprofile_controller.rb b/controllers/email_article_plugin_myprofile_controller.rb index 2d854fc..b74ceb9 100644 --- a/controllers/email_article_plugin_myprofile_controller.rb +++ b/controllers/email_article_plugin_myprofile_controller.rb @@ -5,7 +5,7 @@ class EmailArticlePluginMyprofileController < MyProfileController def send_email if user.is_admin?(profile) article = Article.find(params[:id]) - EmailArticlePluginMyprofileController::Sender.deliver_mail(article) + EmailArticlePluginMyprofileController::Sender.content(article).deliver render :text => "Email sent to queue" else render :status => :forbidden, :text => "Forbidden user" @@ -13,18 +13,20 @@ class EmailArticlePluginMyprofileController < MyProfileController end class Sender < ActionMailer::Base - def mail(article) + def content(article) members = article.profile.members emails = [] members.each{ |m| emails.push(m.user.email) } - content_type 'text/html' - recipients emails - from "#{article.author.user.name} <#{article.author.user.email}>" - reply_to article.author.user.email - subject "[Artigo] " + article.title - body set_absolute_path(article.body, article.environment) + mail( + content_type: 'text/html', + to: emails, + from: "#{article.author.user.name} <#{article.author.user.email}>", + reply_to: article.author.user.email, + subject: "[Artigo] " + article.title, + body: set_absolute_path(article.body, article.environment) + ) end def set_absolute_path(body, environment) @@ -42,4 +44,4 @@ class EmailArticlePluginMyprofileController < MyProfileController end end end -end \ No newline at end of file +end diff --git a/lib/email_article_plugin.rb b/lib/email_article_plugin.rb index ed59a4e..f056f53 100644 --- a/lib/email_article_plugin.rb +++ b/lib/email_article_plugin.rb @@ -13,7 +13,7 @@ class EmailArticlePlugin < Noosfero::Plugin htmlclass = _("button with-text icon-menu-mail") title = _("Email article to all community members") - lambda { + proc { if !profile.blank? and !user.blank? and user.is_admin?(profile) and @page.kind_of?(TextArticle) link_to_remote( label, -- libgit2 0.21.2