[Git][noosfero/noosfero][master] 3 commits: newsletter: Also search blogs by people's and enterprises' names

Bráulio Bhavamitra gitlab at mg.gitlab.com
Thu Mar 17 11:26:02 BRT 2016


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
a729e69f by Larissa Reis at 2016-03-16T22:50:44-03:00
newsletter: Also search blogs by people's and enterprises' names

Now user can search for a blog either by its name or the name of the
profile the blog belongs to, instead of just the blog's or community's
name.

- - - - -
0dc14b08 by Larissa Reis at 2016-03-16T22:50:49-03:00
newsletter: Updates translations

- - - - -
3018162d by Bráulio Bhavamitra at 2016-03-17T14:25:00+00:00
Merge branch 'newsletter-search-all-profiles' into 'master'

newsletter: search blogs also by profile's names

We already allow the admin to choose any blog in the environment to feed the newsletter,
however it's only possible to search a blog by its name or community's name. With this
patch the admin can search for a blog either by its name or the name of the profile the
blog belongs to.

See merge request !706
- - - - -


5 changed files:

- plugins/newsletter/controllers/newsletter_plugin_admin_controller.rb
- plugins/newsletter/features/newsletter_plugin.feature
- plugins/newsletter/po/newsletter.pot
- plugins/newsletter/po/pt/newsletter.po
- plugins/newsletter/views/newsletter_plugin_admin/index.html.erb


Changes:

=====================================
plugins/newsletter/controllers/newsletter_plugin_admin_controller.rb
=====================================
--- a/plugins/newsletter/controllers/newsletter_plugin_admin_controller.rb
+++ b/plugins/newsletter/controllers/newsletter_plugin_admin_controller.rb
@@ -30,14 +30,14 @@ class NewsletterPluginAdminController < PluginAdminController
   end
 
   #TODO: Make this query faster
-  def search_communities
-    communities = environment.communities
+  def search_profiles
+    profiles = environment.profiles
     blogs = Blog.joins(:profile).where(profiles: {environment_id: environment.id})
 
-    found_communities = find_by_contents(:communities, environment, communities, params['q'], {:page => 1})[:results]
+    found_profiles = find_by_contents(:profiles, environment, profiles, params['q'], {:page => 1})[:results]
     found_blogs = find_by_contents(:blogs, environment, blogs, params['q'], {:page => 1})[:results]
 
-    results = (found_blogs + found_communities.map(&:blogs).flatten).uniq
+    results = (found_blogs + found_profiles.map(&:blogs).flatten).uniq
     render :text => results.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} }.to_json
   end
 


=====================================
plugins/newsletter/features/newsletter_plugin.feature
=====================================
--- a/plugins/newsletter/features/newsletter_plugin.feature
+++ b/plugins/newsletter/features/newsletter_plugin.feature
@@ -1,27 +1,21 @@
 Feature: newsletter plugin
 
   Background:
-    Given the following users
-      | login | name |
-      | joaosilva | Joao Silva |
-    And I am logged in as "joaosilva"
+    Given I am logged in as admin
 
   Scenario: as admin I can configure plugin
-    Given I am logged in as admin
     When I go to the environment control panel
     And I follow "Plugins"
     Then I should see "Configuration" linking to "/admin/plugin/newsletter"
 
   Scenario: in the newsletter settings I can see the field to enable/disable
-    Given I am logged in as admin
     When I go to the environment control panel
     And I follow "Plugins"
     And I follow "Configuration"
     Then I should see "Enable send of newsletter to members on this environment"
 
   Scenario: redirect to newsletter visualization after save and visualize
-    Given I am logged in as admin
-    And "NewsletterPlugin" plugin is enabled
+    Given "NewsletterPlugin" plugin is enabled
     When I go to the environment control panel
     And I follow "Plugins"
     And I follow "Configuration"
@@ -30,11 +24,58 @@ Feature: newsletter plugin
     And I should not see "Newsletter settings"
 
   Scenario: stay on newsletter settings page after save
-    Given I am logged in as admin
-    And "NewsletterPlugin" plugin is enabled
+    Given "NewsletterPlugin" plugin is enabled
     When I go to the environment control panel
     And I follow "Plugins"
     And I follow "Configuration"
     And I press "Save"
     Then I should see "Newsletter settings"
     And I should not see "If you can't view this email, click here"
+
+  @selenium
+  Scenario: search community and select blog for newsletter
+    Given the following communities
+      | identifier | name |
+      | sample-community | Sample Community |
+    And the following blogs
+      | owner | name |
+      | sample-community | Sample Blog |
+    And "NewsletterPlugin" plugin is enabled
+    When I go to the environment control panel
+    And I follow "Plugins"
+    And I follow "Configuration"
+    And I type in "Sample Community" into autocomplete list "search-profiles" and I choose "Sample Blog in Sample Community"
+    And I press "Save"
+    Then I should see "Sample Blog in Sample Community"
+
+  @selenium
+  Scenario: search profile and select blog for newsletter
+    Given the following users
+      | login | name |
+      | joaosilva | Joao Silva |
+    And the following blogs
+      | owner | name |
+      | joaosilva | Joao Blog |
+    And "NewsletterPlugin" plugin is enabled
+    When I go to the environment control panel
+    And I follow "Plugins"
+    And I follow "Configuration"
+    And I type in "Silva" into autocomplete list "search-profiles" and I choose "Joao Blog in Joao Silva"
+    And I press "Save"
+    Then I should see "Joao Blog in Joao Silva"
+
+  @selenium
+  Scenario: search blog and select it for newsletter
+    Given the following communities
+      | identifier | name |
+      | sample-community | Sample Community |
+    And the following blogs
+      | owner | name |
+      | sample-community | Sample Blog |
+    And "NewsletterPlugin" plugin is enabled
+    When I go to the environment control panel
+    And I follow "Plugins"
+    And I follow "Configuration"
+    And I type in "Sample Blog" into autocomplete list "search-profiles" and I choose "Sample Blog in Sample Community"
+    And I press "Save"
+    Then I should see "Sample Blog in Sample Community"


=====================================
plugins/newsletter/po/newsletter.pot
=====================================
--- a/plugins/newsletter/po/newsletter.pot
+++ b/plugins/newsletter/po/newsletter.pot
@@ -158,7 +158,7 @@ msgid "Blogs from which news will be compiled"
 msgstr ""
 
 #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36
-msgid "Type in the communities' or blogs' names"
+msgid "Type in the profiles' or blogs' names"
 msgstr ""
 
 #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42


=====================================
plugins/newsletter/po/pt/newsletter.po
=====================================
--- a/plugins/newsletter/po/pt/newsletter.po
+++ b/plugins/newsletter/po/pt/newsletter.po
@@ -164,8 +164,8 @@ msgid "Blogs from which news will be compiled"
 msgstr "Blogs utilizados como fonte do boletim informativo"
 
 #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36
-msgid "Type in the communities' or blogs' names"
-msgstr "Digite nomes de comunidades ou blogs"
+msgid "Type in the profiles' or blogs' names"
+msgstr "Digite nomes de perfis ou blogs"
 
 #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42
 msgid "Recipients"


=====================================
plugins/newsletter/views/newsletter_plugin_admin/index.html.erb
=====================================
--- a/plugins/newsletter/views/newsletter_plugin_admin/index.html.erb
+++ b/plugins/newsletter/views/newsletter_plugin_admin/index.html.erb
@@ -29,11 +29,11 @@
   %>
 
   <p><%= _('Blogs from which news will be compiled') %></p>
-  <% search_action = url_for(:action => 'search_communities') %>
+  <% search_action = url_for(:action => 'search_profiles') %>
   <% selected_blogs = @blogs.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} } %>
   <%= token_input_field_tag(
-    'newsletter[blog_ids]', 'search-communities', search_action,
-    { hint_text: _('Type in the communities\' or blogs\' names'),
+    'newsletter[blog_ids]', 'search-profiles', search_action,
+    { hint_text: _('Type in the profiles\' or blogs\' names'),
       focus: false, pre_populate: selected_blogs }) %>
 
   <br/>



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/b59670025f7633c38fdea98237dac794ce542467...3018162d6165536bf2f2c4a61c142f6b0e24d3a5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160317/8bd9b64d/attachment.html>


More information about the Noosfero-dev mailing list