Commit 95a396f7edbb53065b957c075221cc17e531117a
1 parent
6f962996
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
removing email_article plugin from stable
Showing
5 changed files
with
0 additions
and
141 deletions
Show diff stats
plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb
... | ... | @@ -1,47 +0,0 @@ |
1 | -class EmailArticlePluginMyprofileController < MyProfileController | |
2 | - | |
3 | - needs_profile | |
4 | - | |
5 | - def send_email | |
6 | - if user.is_admin?(profile) | |
7 | - article = Article.find(params[:id]) | |
8 | - EmailArticlePluginMyprofileController::Sender.content(article).deliver | |
9 | - render :text => "Email sent to queue" | |
10 | - else | |
11 | - render :status => :forbidden, :text => "Forbidden user" | |
12 | - end | |
13 | - end | |
14 | - | |
15 | - class Sender < ActionMailer::Base | |
16 | - def content(article) | |
17 | - members = article.profile.members | |
18 | - emails = [] | |
19 | - members.each{ |m| | |
20 | - emails.push(m.user.email) | |
21 | - } | |
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 | - ) | |
30 | - end | |
31 | - | |
32 | - def set_absolute_path(body, environment) | |
33 | - parsed = Hpricot(body.to_s) | |
34 | - parsed.search('img[@src]').map { |i| change_element_path(i, 'src', environment) } | |
35 | - parsed.search('a[@href]').map { |i| change_element_path(i, 'href', environment) } | |
36 | - parsed.to_s | |
37 | - end | |
38 | - | |
39 | - def change_element_path(el, attribute, environment) | |
40 | - fullpath = /^http/.match(el[attribute]) | |
41 | - if not fullpath | |
42 | - relative_path = /\/?(.*)/.match(el[attribute]) | |
43 | - el[attribute] = "http://#{environment.default_hostname}/#{relative_path[1]}" | |
44 | - end | |
45 | - end | |
46 | - end | |
47 | -end |
plugins/email_article/lib/email_article_plugin.rb
... | ... | @@ -1,33 +0,0 @@ |
1 | -class EmailArticlePlugin < Noosfero::Plugin | |
2 | - | |
3 | - def self.plugin_name | |
4 | - "Email Article to Community Members Plugin" | |
5 | - end | |
6 | - | |
7 | - def self.plugin_description | |
8 | - _("A plugin that emails an article to the members of the community") | |
9 | - end | |
10 | - | |
11 | - def article_toolbar_extra_buttons | |
12 | - label = _("Send article to members") | |
13 | - htmlclass = _("button with-text icon-menu-mail") | |
14 | - title = _("Email article to all community members") | |
15 | - | |
16 | - proc { | |
17 | - if !profile.blank? and !user.blank? and user.is_admin?(profile) and @page.kind_of?(TextArticle) | |
18 | - link_to_remote( | |
19 | - label, | |
20 | - { | |
21 | - :url => { :controller => 'email_article_plugin_myprofile', :action => "send_email", :id => @page, :profile => @page.profile}, | |
22 | - :method => :get, | |
23 | - :success => "display_notice('" + _("Messages are being sent") + "')", | |
24 | - :failure => "display_notice('" + _("Error sending emails") + "')", | |
25 | - :confirm => _("Are you sure you want to email this article to all community members?"), | |
26 | - }, | |
27 | - :class => htmlclass, | |
28 | - :title => title | |
29 | - ) | |
30 | - end | |
31 | - } | |
32 | - end | |
33 | -end |
plugins/email_article/test/functional/email_article_plugin_myprofile_controller_test.rb
... | ... | @@ -1,39 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | - | |
3 | -class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase | |
4 | - | |
5 | - def setup | |
6 | - Environment.delete_all | |
7 | - @environment = Environment.new(:name => 'testenv', :is_default => true) | |
8 | - @environment.enabled_plugins = ['EmailArticlePlugin'] | |
9 | - @environment.save! | |
10 | - end | |
11 | - | |
12 | - should 'be able to deliver mail as profile admin' do | |
13 | - @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community') | |
14 | - @user = create_user('testinguser') | |
15 | - login_as(@user.login) | |
16 | - @profile.add_admin(@user.person) | |
17 | - @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) | |
18 | - @article.save | |
19 | - get :send_email, :profile => @profile.identifier, :id => @article.id | |
20 | - assert_response :success | |
21 | - end | |
22 | - | |
23 | - should 'deny access to email article unless if profile admin' do | |
24 | - @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') | |
25 | - @user = create_user('user-out-of-the-community') | |
26 | - login_as(@user.login) | |
27 | - @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) | |
28 | - @article.save | |
29 | - get :send_email, :profile => @profile.identifier, :id => @article.id | |
30 | - assert_response 403 | |
31 | - end | |
32 | - | |
33 | -end | |
34 | - | |
35 | - | |
36 | - | |
37 | - | |
38 | - | |
39 | - |
plugins/email_article/test/test_helper.rb
... | ... | @@ -1 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/../../../test/test_helper' |
plugins/email_article/test/unit/email_article_plugin_test.rb
... | ... | @@ -1,21 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
2 | - | |
3 | -class EmailArticlePluginTest < ActiveSupport::TestCase | |
4 | - | |
5 | - def setup | |
6 | - @plugin = EmailArticlePlugin.new | |
7 | - end | |
8 | - | |
9 | - should 'be a noosfero plugin' do | |
10 | - assert_kind_of Noosfero::Plugin, @plugin | |
11 | - end | |
12 | - | |
13 | - should 'have name' do | |
14 | - assert_equal 'Email Article to Community Members Plugin', EmailArticlePlugin.plugin_name | |
15 | - end | |
16 | - | |
17 | - should 'have description' do | |
18 | - assert_equal _("A plugin that emails an article to the members of the community"), EmailArticlePlugin.plugin_description | |
19 | - end | |
20 | - | |
21 | -end |