Commit b397fec9359cfaffa79f05006ae5852947cb7f86

Authored by Leandro Nunes dos Santos
2 parents 4ed9e248 ce0d03ab

Merge branches 'stable_colivre' and 'ActionItem2823' into ActionItem2823

Showing 154 changed files with 756 additions and 610 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 154 files displayed.

AUTHORS
... ... @@ -44,6 +44,7 @@ Antonio Terceiro <terceiro@colivre.coop.br>
44 44 Aurelio A. Heckert <aurelio@colivre.coop.br>
45 45 Braulio Bhavamitra <brauliobo@gmail.com>
46 46 Bráulio Bhavamitra <brauliobo@gmail.com>
  47 +Braulio Bhavamitra <braulio@eita.org.br>
47 48 Caio <caio.csalgado@gmail.com>
48 49 Caio + Diego + Pedro + João <caio.csalgado@gmail.com>
49 50 Caio Formiga <caio.formiga@gmail.com>
... ... @@ -147,6 +148,7 @@ João M. M. Silva + Rafael Manzo &lt;jaodsilv@linux.ime.usp.br&gt;
147 148 João M. M. Silva + Renan Teruo <jaodsilv@linux.ime.usp.br>
148 149 Joenio Costa <joenio@colivre.coop.br>
149 150 Josef Spillner <josef.spillner@tu-dresden.de>
  151 +Junior Silva <juniorsilva7@juniorsilva-Aspire-5750Z.(none)>
150 152 Keilla Menezes <keilla@colivre.coop.br>
151 153 Larissa Reis <larissa@colivre.coop.br>
152 154 Larissa Reis <reiss.larissa@gmail.com>
... ...
app/controllers/my_profile/manage_products_controller.rb
... ... @@ -6,10 +6,10 @@ class ManageProductsController &lt; ApplicationController
6 6 before_filter :login_required, :except => [:show]
7 7 before_filter :create_product?, :only => [:new]
8 8  
9   - protected
  9 + protected
10 10  
11 11 def check_environment_feature
12   - if profile.environment.enabled?('disable_products_for_enterprises')
  12 + unless profile.environment.enabled?('products_for_enterprises')
13 13 render_not_found
14 14 return
15 15 end
... ...
app/controllers/my_profile/profile_design_controller.rb
... ... @@ -38,7 +38,7 @@ class ProfileDesignController &lt; BoxOrganizerController
38 38 end
39 39  
40 40 # product block exclusive for enterprises in environments that permits it
41   - if profile.enterprise? && !profile.environment.enabled?('disable_products_for_enterprises')
  41 + if profile.enterprise? && profile.environment.enabled?('products_for_enterprises')
42 42 blocks << ProductsBlock
43 43 end
44 44  
... ...
app/controllers/public/catalog_controller.rb
... ... @@ -12,7 +12,7 @@ class CatalogController &lt; PublicController
12 12 protected
13 13  
14 14 def check_enterprise_and_environment
15   - unless profile.kind_of?(Enterprise) && !profile.environment.enabled?('disable_products_for_enterprises')
  15 + unless profile.kind_of?(Enterprise) && @profile.environment.enabled?('products_for_enterprises')
16 16 redirect_to :controller => 'profile', :profile => profile.identifier, :action => 'index'
17 17 end
18 18 end
... ...
app/helpers/boxes_helper.rb
... ... @@ -99,9 +99,11 @@ module BoxesHelper
99 99 unless block.visible?
100 100 options[:title] = _("This block is invisible. Your visitors will not see it.")
101 101 end
  102 +
102 103 if @controller.send(:content_editor?)
103 104 result = filter_html(result, block)
104 105 end
  106 +
105 107 box_decorator.block_target(block.box, block) +
106 108 content_tag('div',
107 109 content_tag('div',
... ...
app/helpers/cms_helper.rb
... ... @@ -28,7 +28,7 @@ module CmsHelper
28 28 end
29 29  
30 30 def link_to_article(article)
31   - article_name = short_filename(article.title, 30)
  31 + article_name = article.title
32 32 if article.folder?
33 33 link_to article_name, {:action => 'view', :id => article.id}, :class => icon_for_article(article)
34 34 else
... ...
app/helpers/profile_editor_helper.rb
... ... @@ -136,7 +136,7 @@ module ProfileEditorHelper
136 136 concat(
137 137 content_tag(
138 138 'div',
139   - capture(&block) + content_tag('br', '', :style => 'clear: left'),
  139 + capture(&block) + tag('br', :style => 'clear: left'),
140 140 :class => 'control-panel')
141 141 )
142 142 end
... ...
app/helpers/profile_helper.rb
1 1 module ProfileHelper
2 2  
3 3 def display_field(title, profile, field, force = false)
4   - if (!force && !profile.active_fields.include?(field.to_s)) ||
5   - (profile.active_fields.include?(field.to_s) && !profile.public_fields.include?(field.to_s) && (!user || (user != profile && !user.is_a_friend?(profile))))
  4 + unless force || profile.may_display_field_to?(field, user)
6 5 return ''
7 6 end
8 7 value = profile.send(field)
... ...
app/models/action_tracker_notification.rb
... ... @@ -3,7 +3,7 @@ class ActionTrackerNotification &lt; ActiveRecord::Base
3 3 belongs_to :profile
4 4 belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id'
5 5  
6   - has_many :comments, :through => :action_tracker, :class_name => 'Comment', :foreign_key => 'source_id'
  6 + delegate :comments, :to => :action_tracker, :allow_nil => true
7 7  
8 8 validates_presence_of :profile_id, :action_tracker_id
9 9 validates_uniqueness_of :action_tracker_id, :scope => :profile_id
... ...
app/models/article.rb
... ... @@ -57,7 +57,7 @@ class Article &lt; ActiveRecord::Base
57 57 has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ]
58 58 has_many :categories, :through => :article_categorizations
59 59  
60   - has_many :article_categorizations_including_virtual, :class_name => 'ArticleCategorization', :dependent => :destroy
  60 + has_many :article_categorizations_including_virtual, :class_name => 'ArticleCategorization'
61 61 has_many :categories_including_virtual, :through => :article_categorizations_including_virtual, :source => :category
62 62  
63 63 acts_as_having_settings :field => :setting
... ...
app/models/category.rb
... ... @@ -22,23 +22,15 @@ class Category &lt; ActiveRecord::Base
22 22  
23 23 named_scope :on_level, lambda { |parent| {:conditions => {:parent_id => parent}} }
24 24  
25   - named_scope :sub_categories, lambda { |category|
26   - {:conditions => ['categories.path LIKE ? AND categories.id != ?', "%#{category.slug}%", category.id]}
27   - }
28   -
29   - named_scope :sub_tree, lambda { |category|
30   - {:conditions => ['categories.path LIKE ?', "%#{category.slug}%"]}
31   - }
32   -
33 25 acts_as_filesystem
34 26  
35   - has_many :article_categorizations, :dependent => :destroy
  27 + has_many :article_categorizations
36 28 has_many :articles, :through => :article_categorizations
37 29 has_many :comments, :through => :articles
38 30  
39 31 has_many :events, :through => :article_categorizations, :class_name => 'Event', :source => :article
40 32  
41   - has_many :profile_categorizations, :dependent => :destroy
  33 + has_many :profile_categorizations
42 34 has_many :profiles, :through => :profile_categorizations, :source => :profile
43 35 has_many :enterprises, :through => :profile_categorizations, :source => :profile, :class_name => 'Enterprise'
44 36 has_many :people, :through => :profile_categorizations, :source => :profile, :class_name => 'Person'
... ...
app/models/enterprise.rb
... ... @@ -134,7 +134,7 @@ class Enterprise &lt; Organization
134 134 [ProfileImageBlock.new, LinkListBlock.new(:links => links)],
135 135 []
136 136 ]
137   - if !environment.enabled?('disable_products_for_enterprises')
  137 + if environment.enabled?('products_for_enterprises')
138 138 blocks[2].unshift ProductsBlock.new
139 139 end
140 140 blocks
... ...
app/models/environment.rb
... ... @@ -95,7 +95,6 @@ class Environment &lt; ActiveRecord::Base
95 95 'disable_asset_communities' => __('Disable search for communities'),
96 96 'disable_asset_products' => _('Disable search for products'),
97 97 'disable_asset_events' => _('Disable search for events'),
98   - 'disable_products_for_enterprises' => __('Disable products for enterprises'),
99 98 'disable_categories' => _('Disable categories'),
100 99 'disable_header_and_footer' => _('Disable header/footer editing by users'),
101 100 'disable_gender_icon' => _('Disable gender icon'),
... ... @@ -103,9 +102,13 @@ class Environment &lt; ActiveRecord::Base
103 102 'disable_select_city_for_contact' => _('Disable state/city select for contact form'),
104 103 'disable_contact_person' => _('Disable contact for people'),
105 104 'disable_contact_community' => _('Disable contact for groups/communities'),
106   - 'enterprise_registration' => __('Enterprise registration'),
107 105  
  106 + 'products_for_enterprises' => __('Enable products for enterprises'),
  107 + 'enterprise_registration' => __('Enterprise registration'),
108 108 'enterprise_activation' => __('Enable activation of enterprises'),
  109 + 'enterprises_are_disabled_when_created' => __('Enterprises are disabled when created'),
  110 + 'enterprises_are_validated_when_created' => __('Enterprises are validated when created'),
  111 +
109 112 'media_panel' => _('Media panel in WYSIWYG editor'),
110 113 'select_preferred_domain' => _('Select preferred domains per profile'),
111 114 'use_portal_community' => _('Use the portal as news source for front page'),
... ... @@ -118,8 +121,6 @@ class Environment &lt; ActiveRecord::Base
118 121 'organizations_are_moderated_by_default' => _("Organizations have moderated publication by default"),
119 122 'enable_organization_url_change' => _("Allow organizations to change their URL"),
120 123 'admin_must_approve_new_communities' => _("Admin must approve creation of communities"),
121   - 'enterprises_are_disabled_when_created' => __('Enterprises are disabled when created'),
122   - 'enterprises_are_validated_when_created' => __('Enterprises are validated when created'),
123 124 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'),
124 125 'xmpp_chat' => _('XMPP/Jabber based chat'),
125 126 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'),
... ... @@ -281,8 +282,9 @@ class Environment &lt; ActiveRecord::Base
281 282 end
282 283  
283 284 # Enables a feature identified by its name
284   - def enable(feature)
  285 + def enable(feature, must_save=true)
285 286 self.settings["#{feature}_enabled".to_sym] = true
  287 + self.save! if must_save
286 288 end
287 289  
288 290 def enable_plugin(plugin)
... ... @@ -292,8 +294,9 @@ class Environment &lt; ActiveRecord::Base
292 294 end
293 295  
294 296 # Disables a feature identified by its name
295   - def disable(feature)
  297 + def disable(feature, must_save=true)
296 298 self.settings["#{feature}_enabled".to_sym] = false
  299 + self.save! if must_save
297 300 end
298 301  
299 302 def disable_plugin(plugin)
... ... @@ -337,7 +340,7 @@ class Environment &lt; ActiveRecord::Base
337 340 %w(
338 341 disable_asset_products
339 342 disable_gender_icon
340   - disable_products_for_enterprises
  343 + products_for_enterprises
341 344 disable_select_city_for_contact
342 345 enterprise_registration
343 346 media_panel
... ... @@ -345,7 +348,7 @@ class Environment &lt; ActiveRecord::Base
345 348 show_balloon_with_profile_links_when_clicked
346 349 use_portal_community
347 350 ).each do |feature|
348   - enable(feature)
  351 + enable(feature, false)
349 352 end
350 353 end
351 354  
... ...
app/models/featured_products_block.rb
... ... @@ -7,8 +7,9 @@ class FeaturedProductsBlock &lt; Block
7 7  
8 8 before_save do |block|
9 9 if block.owner.kind_of?(Environment) && block.product_ids.blank?
10   - seed = block.owner.products.count
11   - block.product_ids = block.owner.highlighted_products_with_image(:offset => (rand(seed) % (seed - block.groups_of * 3)), :limit => block.groups_of * 3).map(&:id)
  10 + total = block.owner.products.count
  11 + offset = rand([(total - block.groups_of * 3) + 1, 1].max)
  12 + block.product_ids = block.owner.highlighted_products_with_image(:offset => offset, :limit => block.groups_of * 3).map(&:id)
12 13 end
13 14 block.groups_of = block.groups_of.to_i
14 15 end
... ...
app/models/person.rb
... ... @@ -471,8 +471,9 @@ class Person &lt; Profile
471 471 Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.user_id = #{self.id} and action_tracker.verb != 'leave_scrap_to_self' and action_tracker.verb != 'add_member_in_community' ORDER BY updated_at DESC")
472 472 end
473 473  
  474 + # by default, all fields are private
474 475 def public_fields
475   - self.fields_privacy.nil? ? self.active_fields : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s)
  476 + self.fields_privacy.nil? ? [] : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s)
476 477 end
477 478  
478 479 protected
... ...
app/models/price_detail.rb
... ... @@ -4,11 +4,11 @@ class PriceDetail &lt; ActiveRecord::Base
4 4 validates_presence_of :product_id
5 5  
6 6 belongs_to :production_cost
7   - validates_presence_of :production_cost
  7 + # Do not validates_presence_of production_cost. We may have undefined other costs.
8 8 validates_uniqueness_of :production_cost_id, :scope => :product_id
9 9  
10 10 def name
11   - production_cost.name
  11 + production_cost.nil? ? _('Other costs') : production_cost.name
12 12 end
13 13  
14 14 def price
... ...
app/models/product.rb
... ... @@ -191,11 +191,13 @@ class Product &lt; ActiveRecord::Base
191 191 (price - total_production_cost.to_f).zero?
192 192 end
193 193  
194   - def update_price_details(price_details)
195   - self.price_details.destroy_all
196   - price_details.each do |price_detail|
197   - self.price_details.create(price_detail)
  194 + def update_price_details(new_price_details)
  195 + price_details.destroy_all
  196 + new_price_details.each do |detail|
  197 + price_details.create(detail)
198 198 end
  199 + reload # to remove temporary duplicated price_details
  200 + price_details
199 201 end
200 202  
201 203 def price_description_percentage
... ...
app/models/profile.rb
... ... @@ -226,12 +226,14 @@ class Profile &lt; ActiveRecord::Base
226 226  
227 227 belongs_to :region
228 228  
  229 + LOCATION_FIELDS = %w[address district city state country_name zip_code]
  230 +
229 231 def location(separator = ' - ')
230 232 myregion = self.region
231 233 if myregion
232 234 myregion.hierarchy.reverse.first(2).map(&:name).join(separator)
233 235 else
234   - %w[address district city state country_name zip_code ].map {|item| (self.respond_to?(item) && !self.send(item).blank?) ? self.send(item) : nil }.compact.join(separator)
  236 + LOCATION_FIELDS.map {|item| (self.respond_to?(item) && !self.send(item).blank?) ? self.send(item) : nil }.compact.join(separator)
235 237 end
236 238 end
237 239  
... ... @@ -882,6 +884,21 @@ private :generate_url, :url_options
882 884 []
883 885 end
884 886  
  887 + def may_display_field_to? field, user = nil
  888 + if not self.active_fields.include? field.to_s
  889 + self.send "may_display_#{field}_to?", user rescue true
  890 + else
  891 + not (!self.public_fields.include? field.to_s and (!user or (user != self and !user.is_a_friend?(self))))
  892 + end
  893 + end
  894 +
  895 + def may_display_location_to? user = nil
  896 + LOCATION_FIELDS.each do |field|
  897 + return false if !self.may_display_field_to? field, user
  898 + end
  899 + return true
  900 + end
  901 +
885 902 # field => privacy (e.g.: "address" => "public")
886 903 def fields_privacy
887 904 self.data[:fields_privacy]
... ...
app/models/profile_list_block.rb
... ... @@ -54,7 +54,7 @@ class ProfileListBlock &lt; Block
54 54 list = content_tag 'ul', nl +' '+ list + nl
55 55 end
56 56 block_title(title) + nl +
57   - content_tag('div', nl + list + nl + content_tag('br', '', :style => 'clear:both'))
  57 + content_tag('div', nl + list + nl + tag('br', :style => 'clear:both'))
58 58 end
59 59 end
60 60  
... ...
app/models/region.rb
... ... @@ -8,9 +8,9 @@ class Region &lt; Category
8 8 validators.count > 0
9 9 end
10 10  
11   - named_scope :with_validators, :group => 'id',
  11 + named_scope :with_validators, :select => 'DISTINCT ON (categories.id) *',
12 12 :joins => 'INNER JOIN region_validators on (region_validators.region_id = categories.id)'
13   -
  13 +
14 14 end
15 15  
16 16 require_dependency 'city'
... ...
app/sweepers/profile_sweeper.rb
... ... @@ -4,7 +4,7 @@ class ProfileSweeper # &lt; ActiveRecord::Observer
4 4 include SweeperHelper
5 5  
6 6 def after_update(profile)
7   - expire_caches(profile)
  7 + self.delay.expire_caches profile
8 8 end
9 9  
10 10 def after_create(profile)
... ...
app/views/blocks/profile_info.rhtml
... ... @@ -17,7 +17,7 @@
17 17 <ul class="profile-info-data" id="profile-info-data-<%= block.id %>">
18 18 <li><%= link_to __('Homepage'), block.owner.url, :class => 'url' %></li>
19 19 <li><%= link_to _('View profile'), block.owner.public_profile_url %></li>
20   - <% if block.owner.enterprise? && !block.owner.environment.enabled?('disable_products_for_enterprises') %>
  20 + <% if block.owner.enterprise? && block.owner.environment.enabled?('products_for_enterprises') %>
21 21 <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li>
22 22 <% end %>
23 23 <li id="profile-admin-url-<%= block.id %>"></li>
... ...
app/views/cms/view.rhtml
... ... @@ -41,7 +41,7 @@
41 41 <% end %>
42 42  
43 43 <% @articles.each do |article| %>
44   - <tr>
  44 + <tr title="<%= article.title%>" >
45 45 <td>
46 46 <%= link_to_article(article) %>
47 47 </td>
... ...
app/views/content_viewer/_enterprise_homepage.rhtml
1 1 <%= display_profile_info enterprise_homepage.profile %>
2 2 <div><%= enterprise_homepage.body %></div>
3   -<%= render :file => 'catalog/index' unless enterprise_homepage.profile.environment.enabled?('disable_products_for_enterprises') %>
  3 +<%= render :file => 'catalog/index' if enterprise_homepage.profile.environment.enabled?('products_for_enterprises') %>
... ...
app/views/manage_products/_display_price_details.rhtml
... ... @@ -10,7 +10,7 @@
10 10 </li>
11 11 <% @product.price_details.each do |price_detail| %>
12 12 <li>
13   - <div class='price-detail-name'><%= "%s:" % price_detail.production_cost.name %></div>
  13 + <div class='price-detail-name'><%= "%s:" % price_detail.name %></div>
14 14 <div class='price-detail-price'><%= float_to_currency(price_detail.price) %></div>
15 15 </li>
16 16 <% end %>
... ...
app/views/manage_products/_edit_price_details.rhtml
1 1 <% price_details.each do |price_detail| %>
2 2 <tr id='<%= "price-detail-#{price_detail.id}" %>'>
3 3 <td><%= select_production_cost(@product, price_detail.production_cost_id) %></td>
4   - <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', price_detail.formatted_value(:price), :class => 'numbers-only price-details-price')) %></td>
  4 + <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', price_detail.formatted_value(:price), :class => 'numbers-only price-details-price', :size => 6)) %></td>
5 5 <td>
6 6 <%= link_to_remote(_('Remove'),
7 7 :update => "price-detail-#{price_detail.id}",
... ...
app/views/manage_products/_manage_product_details.rhtml
... ... @@ -34,7 +34,7 @@
34 34 <table id='new-cost-fields'>
35 35 <tr>
36 36 <td><%= select_production_cost(@product) %></td>
37   - <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', nil, :class => 'numbers-only price-details-price')) %></td>
  37 + <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', nil, :class => 'numbers-only price-details-price', :size => 6)) %></td>
38 38 <td><%= link_to(_('Cancel'), '#', {:class => 'cancel-new-cost'}) %></td>
39 39 </tr>
40 40 </table>
... ...
app/views/profile/_organization_profile.rhtml
... ... @@ -19,7 +19,7 @@
19 19 <td><%= show_date(profile.created_at) %></td>
20 20 </tr>
21 21  
22   - <% if profile.kind_of?(Enterprise) && !profile.environment.enabled?('disable_products_for_enterprises') %>
  22 + <% if profile.kind_of?(Enterprise) && profile.environment.enabled?('products_for_enterprises') %>
23 23 <tr>
24 24 <td></td>
25 25 <td>
... ...
app/views/profile/_person_profile.rhtml
... ... @@ -18,18 +18,6 @@
18 18 <% cache_timeout(profile.relationships_cache_key, 4.hours) do %>
19 19 <%= display_work_info profile %>
20 20  
21   - <% if !environment.enabled?('disable_asset_enterprises') && !profile.enterprises.empty? %>
22   - <tr>
23   - <th colspan='2'><%= __('Enterprises') %></th>
24   - </tr>
25   - <% profile.enterprises.includes(:environment,:domains, :preferred_domain).each do |item| %>
26   - <tr>
27   - <td></td>
28   - <td><%= button 'menu-enterprise', item.name, item.url %></td>
29   - </tr>
30   - <% end %>
31   - <% end %>
32   -
33 21 <tr>
34 22 <th colspan='2'><%= _('Network')%></th>
35 23 </tr>
... ... @@ -41,6 +29,12 @@
41 29 <td><%= __('Communities') + ':' %></td>
42 30 <td><%= link_to profile.communities.count, :controller => "profile", :action => 'communities' %></td>
43 31 </tr>
  32 + <% if environment.disabled?('disable_asset_enterprises') %>
  33 + <tr id="person-profile-network-enterprises">
  34 + <td><%= __('Enterprises') + ':' %></td>
  35 + <td><%= link_to profile.enterprises.count, :controller => "profile", :action => 'enterprises' %></td>
  36 + </tr>
  37 + <% end %>
44 38  
45 39 <%= render :partial => 'common' %>
46 40  
... ...
app/views/profile_editor/index.rhtml
... ... @@ -45,7 +45,7 @@
45 45  
46 46 <%= control_panel_button(_('Manage Members'), 'members', :controller => 'profile_members') if profile.organization? && user.has_permission?(:manage_memberships, profile) %>
47 47  
48   - <%= control_panel_button(_('Manage Products and Services'), 'products', :controller => 'manage_products') if profile.enterprise? && !environment.enabled?('disable_products_for_enterprises') %>
  48 + <%= control_panel_button(_('Manage Products and Services'), 'products', :controller => 'manage_products') if profile.enterprise? && environment.enabled?('products_for_enterprises') %>
49 49  
50 50 <% if !environment.enabled?('disable_asset_enterprises') %>
51 51 <% if profile.is_validation_entity? %>
... ...
app/views/profile_members/_members_list.rhtml
... ... @@ -10,7 +10,7 @@
10 10 <th><%= _('Actions') %></th>
11 11 </tr>
12 12 <% collection.each do |m| %>
13   - <tr>
  13 + <tr title="<%= m.name %>">
14 14 <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td>
15 15 <td>
16 16 <div class="members-buttons-cell">
... ...
app/views/search/_full_article.html.erb
1 1 <li class="search-article-item article-item">
2   - <%= link_to(article.title, article.url, :class => "search-result-title") %>
  2 + <div>
  3 + <%= link_to(article.title, article.url, :class => "search-result-title") %>
  4 + </div>
  5 +
3 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => article %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <%= render :partial => 'article_common', :object => article %>
8 12 </table>
... ...
app/views/search/_full_blog.html.erb
1 1 <li class="search-blog article-item">
2   - <%= link_to blog.title, blog.view_url, :class => 'search-result-title' %>
  2 + <div>
  3 + <%= link_to blog.title, blog.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => blog %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <tr class="search-blog-items">
8 12 <td class="search-field-label"><%= _("Last posts") %></td>
... ...
app/views/search/_full_event.html.erb
1 1 <li class="search-event-item article-item">
2   -<%= link_to(event.title, event.url, :class => "search-result-title") %>
3   -<div class="search-content-first-column">
4   - <%= render :partial => 'image', :object => event %>
5   -</div>
6   -<table class="noborder search-content-second-column">
7   - <% if event.start_date %>
8   - <tr class="search-article-event-date">
9   - <td class="search-field-label"><%= _('Start date') %></td>
10   - <td class="article-item-date"><%= event.start_date %></td>
11   - </tr>
12   - <% end %>
13   - <% if event.end_date %>
14   - <tr class="search-article-event-date">
15   - <td class="search-field-label"><%= _('End date') %></td>
16   - <td class="article-item-date"><%= event.end_date %></td>
17   - </tr>
18   - <% end %>
  2 + <div>
  3 + <%= link_to(event.title, event.url, :class => "search-result-title") %>
  4 + </div>
19 5  
20   - <%= render :partial => 'article_common', :object => event %>
21   -</table>
22   -<%= render :partial => 'article_last_change', :object => event %>
  6 + <div class="search-content-first-column">
  7 + <%= render :partial => 'image', :object => event %>
  8 + </div>
23 9  
24   -<div style="clear: both"></div>
  10 + <table class="noborder search-content-second-column">
  11 + <% if event.start_date %>
  12 + <tr class="search-article-event-date">
  13 + <td class="search-field-label"><%= _('Start date') %></td>
  14 + <td class="article-item-date"><%= event.start_date %></td>
  15 + </tr>
  16 + <% end %>
  17 + <% if event.end_date %>
  18 + <tr class="search-article-event-date">
  19 + <td class="search-field-label"><%= _('End date') %></td>
  20 + <td class="article-item-date"><%= event.end_date %></td>
  21 + </tr>
  22 + <% end %>
  23 +
  24 + <%= render :partial => 'article_common', :object => event %>
  25 + </table>
  26 + <%= render :partial => 'article_last_change', :object => event %>
  27 +
  28 + <div style="clear: both"></div>
25 29 </li>
... ...
app/views/search/_full_folder.html.erb
1 1 <li class="search-folder-item article-item">
2   - <%= link_to folder.title, folder.view_url, :class => 'search-result-title' %>
  2 + <div>
  3 + <%= link_to folder.title, folder.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => folder %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <tr class="search-folder-items">
8 12 <td class="search-field-label"><%= _("Last items") %></td>
... ...
app/views/search/_full_forum.html.erb
1 1 <li class="search-forum-item article-item">
2   - <%= link_to forum.title, forum.view_url, :class => 'search-result-title' %>
  2 + <div>
  3 + <%= link_to forum.title, forum.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => forum %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <tr class="search-forum-items">
8 12 <td class="search-field-label"><%= _("Last topics") %></td>
... ...
app/views/search/_full_gallery.html.erb
1 1 <li class="search-gallery article-item">
2   - <%= link_to gallery.title, gallery.view_url, :class => 'search-result-title' %>
  2 + <div>
  3 + <%= link_to gallery.title, gallery.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => gallery %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <%= render :partial => 'article_common', :object => gallery %>
8 12 </table>
... ...
app/views/search/_full_text_article.html.erb
1 1 <li class="search-text-article-item article-item">
2   - <%= link_to(text_article.title, text_article.url, :class => "search-result-title") %>
  2 + <div>
  3 + <%= link_to(text_article.title, text_article.url, :class => "search-result-title") %>
  4 + </div>
3 5  
4 6 <div class="search-content-first-column">
5 7 <%= render :partial => 'image', :object => text_article %>
... ...
app/views/search/_full_uploaded_file.html.erb
1 1 <li class="search-uploaded-file-item article-item">
2   - <%= link_to uploaded_file.filename, uploaded_file.view_url, :class => 'search-result-title' %>
  2 + <div>
  3 + <%= link_to uploaded_file.filename, uploaded_file.view_url, :class => 'search-result-title' %>
  4 + </div>
3 5  
4 6 <div class="search-content-first-column">
5 7 <%= render :partial => 'image', :object => uploaded_file %>
... ...
app/views/shared/tiny_mce.rhtml
... ... @@ -70,7 +70,7 @@ tinyMCE.init({
70 70 paste_insert_word_content_callback : "convertWord",
71 71 paste_use_dialog: false,
72 72 apply_source_formatting : true,
73   - extended_valid_elements : "applet[style|archive|codebase|code|height|width],comment,iframe[src|style|allowtransparency|frameborder|width|height|scrolling],embed[title|src|type|height|width]",
  73 + extended_valid_elements : "applet[style|archive|codebase|code|height|width],comment,iframe[src|style|allowtransparency|frameborder|width|height|scrolling],embed[title|src|type|height|width],audio[controls|autoplay],video[controls|autoplay],source[src|type]",
74 74 content_css: '/stylesheets/tinymce.css,<%= macro_css_files %>',
75 75 language: <%= tinymce_language.inspect %>,
76 76 entity_encoding: 'raw',
... ...
config/environment.rb
... ... @@ -85,10 +85,10 @@ Rails::Initializer.run do |config|
85 85 }
86 86  
87 87 # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper
88   - config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style', 'target', 'codebase', 'archive', 'classid', 'code', 'flashvars', 'scrolling', 'frameborder'
  88 + config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style', 'target', 'codebase', 'archive', 'classid', 'code', 'flashvars', 'scrolling', 'frameborder', 'controls', 'autoplay'
89 89  
90 90 # Adds custom tags to the Set of allowed html tags for the #sanitize helper
91   - config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe'
  91 + config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe', 'audio', 'video', 'source'
92 92  
93 93 # See Rails::Configuration for more options
94 94  
... ...
db/migrate/20130529155000_rename_environment_setting_disable_products.rb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +class RenameEnvironmentSettingDisableProducts < ActiveRecord::Migration
  2 + def self.up
  3 + select_all("select id from environments").each do |environment|
  4 + env = Environment.find(environment['id'])
  5 + env.settings[:products_for_enterprises_enabled] =
  6 + !env.settings[:disable_products_for_enterprises_enabled]
  7 + env.settings.delete :disable_products_for_enterprises_enabled
  8 + env.save!
  9 + end
  10 + end
  11 +
  12 + def self.down
  13 + select_all("select id from environments").each do |environment|
  14 + env = Environment.find(environment['id'])
  15 + env.settings[:disable_products_for_enterprises_enabled] =
  16 + !env.settings[:products_for_enterprises_enabled]
  17 + env.settings.delete :products_for_enterprises_enabled
  18 + env.save!
  19 + end
  20 + end
  21 +end
... ...
db/schema.rb
... ... @@ -221,7 +221,6 @@ ActiveRecord::Schema.define(:version =&gt; 20130711213046) do
221 221 t.string "source_type"
222 222 t.string "user_agent"
223 223 t.string "referrer"
224   - t.integer "group_id"
225 224 end
226 225  
227 226 add_index "comments", ["source_id", "spam"], :name => "index_comments_on_source_id_and_spam"
... ...
debian/changelog
  1 +noosfero (0.44.4) unstable; urgency=low
  2 +
  3 + * Bugfix release
  4 +
  5 + -- Rodrigo Souto <rodrigo@colivre.coop.br> Mon, 07 Oct 2013 13:38:31 -0300
  6 +
1 7 noosfero (0.44.3) unstable; urgency=low
2 8  
3 9 * Bugfixes release
... ...
features/edit_article.feature
... ... @@ -64,8 +64,8 @@ Feature: edit article
64 64 And I fill in "Tag list" with "aurium, bug"
65 65 And I press "Save"
66 66 And I go to /joaosilva/article-with-tags
67   - Then I should see "aurium" within "#article-tags a:first"
68   - And I should see "bug" within "#article-tags a:last"
  67 + Then I should see "aurium" within "#article-tags"
  68 + And I should see "bug" within "#article-tags"
69 69  
70 70 Scenario: redirect to the created article
71 71 Given I am on joaosilva's control panel
... ...
features/last_administrator_leaving.feature
... ... @@ -17,7 +17,7 @@ Feature: remove administrator role
17 17 Scenario: the last administrator removes his administrator role and must choose the new administrator
18 18 Given "Maria Souza" is a member of "Nice people"
19 19 And I am on Nice people's members management
20   - And I follow "Edit"
  20 + And I follow "Edit" within "tr[title='Joao Silva']"
21 21 And I uncheck "Profile Administrator"
22 22 When I press "Save changes"
23 23 Then I should see "Since you are the last administrator, you must choose"
... ...
features/plugins.feature
... ... @@ -22,27 +22,27 @@ Feature: plugins
22 22 | profile_tabs | lambda { {:title => 'Test plugin tab', :id => 'test_plugin', :content => lambda {'Test plugin random content'} } } |
23 23  
24 24 Scenario: a user must see the plugin\'s button in the control panel if the plugin is enabled
25   - Given plugin TestPlugin is enabled on environment
  25 + Given plugin Test is enabled on environment
26 26 And I go to joaosilva's control panel
27 27 Then I should see "Test plugin button"
28 28  
29 29 Scenario: a user must see the plugin\'s tab in in the profile if the plugin is enabled
30   - Given plugin TestPlugin is enabled on environment
  30 + Given plugin Test is enabled on environment
31 31 And I am on joaosilva's profile
32 32 Then I should see "Test plugin tab"
33 33  
34 34 Scenario: a user must not see the plugin\'s button in the control panel if the plugin is disabled
35   - Given plugin TestPlugin is disabled on environment
  35 + Given plugin Test is disabled on environment
36 36 And I go to joaosilva's control panel
37 37 Then I should not see "Test plugin button"
38 38  
39 39 Scenario: a user must not see the plugin\'s tab in in the profile if the plugin is disabled
40   - Given plugin TestPlugin is disabled on environment
  40 + Given plugin Test is disabled on environment
41 41 And I am on joaosilva's profile
42 42 Then I should not see "Test plugin tab"
43 43  
44 44 Scenario: an admin should be able to deactivate a plugin
45   - Given plugin TestPlugin is enabled on environment
  45 + Given plugin Test is enabled on environment
46 46 And I am logged in as admin
47 47 When I go to admin_user's control panel
48 48 Then I should see "Test plugin button"
... ...
features/search_communities.feature
... ... @@ -4,7 +4,8 @@ Feature: search communities
4 4 In order to find ones that interest me
5 5  
6 6 Background:
7   - Given the following category
  7 + Given plugin Solr is enabled on environment
  8 + And the following category
8 9 | name |
9 10 | social network |
10 11 And the following community
... ...
features/short_filename.feature
... ... @@ -18,4 +18,4 @@ Feature: sitemap
18 18 Scenario: view the CMS
19 19 Given I am logged in as "joaosilva"
20 20 When I am on /myprofile/joaosilva/cms
21   - Then I should see "AGENDA_CULTURA_-_FEST(...).txt"
  21 + Then I should see "AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_(...).txt"
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -44,7 +44,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do |
44 44 end
45 45 if category && !category.blank?
46 46 cat = Category.find_by_slug category
47   - organization.categories << cat
  47 + ProfileCategorization.add_category_to_profile(cat, organization)
48 48 end
49 49 if img_name
50 50 img = Image.create!(:uploaded_data => fixture_file_upload('/files/'+img_name+'.png', 'image/png'))
... ...
features/step_definitions/plugin_steps.rb
... ... @@ -23,6 +23,7 @@ end
23 23  
24 24 Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status|
25 25 e = Environment.default
  26 + plugin = "#{plugin}Plugin"
26 27 if status == 'enabled'
27 28 e.enabled_plugins += [plugin]
28 29 else
... ...
lib/noosfero.rb
... ... @@ -3,7 +3,7 @@ require &#39;fast_gettext&#39;
3 3  
4 4 module Noosfero
5 5 PROJECT = 'noosfero'
6   - VERSION = '0.44.3'
  6 + VERSION = '0.44.4'
7 7  
8 8 def self.pattern_for_controllers_in_directory(dir)
9 9 disjunction = controllers_in_directory(dir).join('|')
... ...
lib/noosfero/plugin.rb
... ... @@ -64,6 +64,9 @@ class Noosfero::Plugin
64 64 require init.gsub(/.rb$/, '') if File.file? init
65 65 end
66 66  
  67 + # load extensions
  68 + Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file }
  69 +
67 70 # load class
68 71 klass(plugin_name)
69 72 end
... ...
plugins/bsc/install.rb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +raise "Not ready yet"
... ...
plugins/bsc/lib/bsc_plugin.rb
1   -require_dependency 'bsc_plugin/ext/enterprise'
2   -require_dependency 'bsc_plugin/ext/product'
3   -
4 1 class BscPlugin < Noosfero::Plugin
5 2  
6 3 Bsc
... ...
plugins/comment_group/lib/comment_group_plugin.rb
1   -require_dependency 'comment_group_plugin/ext/article'
2   -require_dependency 'comment_group_plugin/ext/comment'
3   -
4 1 class CommentGroupPlugin < Noosfero::Plugin
5 2  
6 3 def self.plugin_name
... ...
plugins/comment_group/lib/comment_group_plugin/ext/article.rb
... ... @@ -1,21 +0,0 @@
1   -require_dependency 'article'
2   -
3   -class Article
4   -
5   - #FIXME make this test
6   - has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL']
7   -
8   - #FIXME make this test
9   - validate :not_empty_group_comments_removed
10   -
11   - #FIXME make this test
12   - def not_empty_group_comments_removed
13   - if body
14   - groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq
15   - groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i}
16   - errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty?
17   - end
18   - end
19   -
20   -end
21   -
plugins/comment_group/lib/comment_group_plugin/ext/comment.rb
... ... @@ -1,12 +0,0 @@
1   -require_dependency 'comment'
2   -
3   -class Comment
4   -
5   - named_scope :without_group, :conditions => {:group_id => nil }
6   -
7   - named_scope :in_group, lambda { |group_id| {
8   - :conditions => ['group_id = ?', group_id]
9   - }
10   - }
11   -
12   -end
plugins/comment_group/lib/ext/article.rb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +require_dependency 'article'
  2 +
  3 +class Article
  4 +
  5 + #FIXME make this test
  6 + has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL']
  7 +
  8 + #FIXME make this test
  9 + validate :not_empty_group_comments_removed
  10 +
  11 + #FIXME make this test
  12 + def not_empty_group_comments_removed
  13 + if body
  14 + groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq
  15 + groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i}
  16 + errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty?
  17 + end
  18 + end
  19 +
  20 +end
  21 +
... ...
plugins/comment_group/lib/ext/comment.rb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +require_dependency 'comment'
  2 +
  3 +class Comment
  4 +
  5 + named_scope :without_group, :conditions => {:group_id => nil }
  6 +
  7 + named_scope :in_group, lambda { |group_id| {
  8 + :conditions => ['group_id = ?', group_id]
  9 + }
  10 + }
  11 +
  12 +end
... ...
plugins/comment_group/test/unit/comment_group_plugin_test.rb
... ... @@ -10,15 +10,17 @@ class CommentGroupPluginTest &lt; ActiveSupport::TestCase
10 10  
11 11 attr_reader :environment
12 12  
13   - should 'filter_comments returns all the comments wihout group of an article passed as parameter' do
14   - article = fast_create(Article)
15   - c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
16   - c2 = fast_create(Comment, :source_id => article.id)
17   - c3 = fast_create(Comment, :source_id => article.id)
18   -
19   - plugin = CommentGroupPlugin.new
20   - assert_equal [], [c2, c3] - plugin.filter_comments(article.comments)
21   - assert_equal [], plugin.filter_comments(article.comments) - [c2, c3]
22   - end
  13 +#FIXME Obsolete test
  14 +#
  15 +# should 'filter_comments returns all the comments wihout group of an article passed as parameter' do
  16 +# article = fast_create(Article)
  17 +# c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
  18 +# c2 = fast_create(Comment, :source_id => article.id)
  19 +# c3 = fast_create(Comment, :source_id => article.id)
  20 +#
  21 +# plugin = CommentGroupPlugin.new
  22 +# assert_equal [], [c2, c3] - plugin.filter_comments(article.comments)
  23 +# assert_equal [], plugin.filter_comments(article.comments) - [c2, c3]
  24 +# end
23 25  
24 26 end
... ...
plugins/custom_forms/db/migrate/20130822001407_set_position_to_existent_custom_forms_plugin_fields.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class SetPositionToExistentCustomFormsPluginFields < ActiveRecord::Migration
  2 + def self.up
  3 + update("UPDATE custom_forms_plugin_fields SET position = 0 WHERE position IS NULL")
  4 + end
  5 +
  6 + def self.down
  7 + say("Nothing to undo (cannot recover the data)")
  8 + end
  9 +end
... ...
plugins/custom_forms/lib/custom_forms_plugin.rb
1   -require 'ext/role_assignment_trigger'
2   -
3 1 class CustomFormsPlugin < Noosfero::Plugin
4 2  
5 3 def self.plugin_name
... ...
plugins/custom_forms/lib/custom_forms_plugin/field.rb
... ... @@ -15,8 +15,12 @@ class CustomFormsPlugin::Field &lt; ActiveRecord::Base
15 15  
16 16 before_create do |field|
17 17 if field.form.fields.exists?
18   - field.position = field.form.fields.order('position').last.position + 1
  18 + field.position = field.form.fields.order(:position).last.position + 1
19 19 end
20 20 end
  21 +
  22 + def position
  23 + self[:position] || 0
  24 + end
21 25 end
22 26  
... ...
plugins/custom_forms/test/unit/custom_forms_plugin/field_test.rb
... ... @@ -81,5 +81,17 @@ class CustomFormsPlugin::FieldTest &lt; ActiveSupport::TestCase
81 81 assert_equal 1, field_1.position
82 82 assert_equal 2, field_2.position
83 83 end
  84 +
  85 + should 'not crash when adding new fields on a form with fields without position' do
  86 + form = CustomFormsPlugin::Form.create(:name => 'Free Software', :profile => fast_create(Profile))
  87 + field_0 = CustomFormsPlugin::Field.create(:name => 'License', :form => form)
  88 + field_0.position = nil
  89 + field_0.save
  90 +
  91 + assert_nothing_raised do
  92 + field_1 = CustomFormsPlugin::Field.create!(:name => 'URL', :form => form)
  93 + end
  94 + end
  95 +
84 96 end
85 97  
... ...
plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
... ... @@ -41,7 +41,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
41 41 Article.delete_all
42 42 get :index, :block_id => block.id
43 43 json_response = ActiveSupport::JSON.decode(@response.body)
44   - assert_equal [], json_response
  44 + assert_equivalent [], json_response
45 45 end
46 46  
47 47 should 'index action returns an json with node content' do
... ... @@ -53,7 +53,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
53 53 expected_json = {'data' => article.title}
54 54 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
55 55  
56   - assert_equal [expected_json], json_response
  56 + assert_equivalent [expected_json], json_response
57 57 end
58 58  
59 59 should 'index action returns an json with node checked if the node is in the nodes list' do
... ... @@ -68,7 +68,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
68 68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
69 69 expected_json['attr'].merge!({'class' => 'jstree-checked'})
70 70  
71   - assert_equal [expected_json], json_response
  71 + assert_equivalent [expected_json], json_response
72 72 end
73 73  
74 74 should 'index action returns an json with node undetermined if the node is in the parent nodes list' do
... ... @@ -84,7 +84,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
84 84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'})
85 85 expected_json['children'] = []
86 86  
87   - assert_equal [expected_json], json_response
  87 + assert_equivalent [expected_json], json_response
88 88 end
89 89  
90 90 should 'index action returns an json with node closed if the node has article with children' do
... ... @@ -98,7 +98,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
98 98 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
99 99 expected_json['state'] = 'closed'
100 100  
101   - assert_equal [expected_json], json_response
  101 + assert_equivalent [expected_json], json_response
102 102 end
103 103  
104 104 should 'index action returns an json with all the children nodes if some parent is in the parents list' do
... ... @@ -121,7 +121,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
121 121 expected_json['children'] = children
122 122 expected_json['state'] = 'closed'
123 123  
124   - assert_equal [expected_json], json_response
  124 + assert_equivalent [expected_json], json_response
125 125 end
126 126  
127 127 should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do
... ... @@ -151,7 +151,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
151 151 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
152 152 expected_json.push(value)
153 153  
154   - assert_equal expected_json, json_response
  154 + assert_equivalent expected_json, json_response
155 155 end
156 156  
157 157 should 'index action returns an json without children nodes if the parent is not in the parents list' do
... ... @@ -173,7 +173,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
173 173 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
174 174 expected_json.push(value)
175 175  
176   - assert_equal expected_json, json_response
  176 + assert_equivalent expected_json, json_response
177 177 end
178 178  
179 179 end
... ...
plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
... ... @@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
41 41 Article.delete_all
42 42 get :index, :block_id => block.id, :profile => profile.identifier
43 43 json_response = ActiveSupport::JSON.decode(@response.body)
44   - assert_equal [], json_response
  44 + assert_equivalent [], json_response
45 45 end
46 46  
47 47 should 'index action returns an json with node content' do
... ... @@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
53 53 expected_json = {'data' => article.title}
54 54 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
55 55  
56   - assert_equal [expected_json], json_response
  56 + assert_equivalent [expected_json], json_response
57 57 end
58 58  
59 59 should 'index action returns an json with node checked if the node is in the nodes list' do
... ... @@ -68,7 +68,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
68 68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
69 69 expected_json['attr'].merge!({'class' => 'jstree-checked'})
70 70  
71   - assert_equal [expected_json], json_response
  71 + assert_equivalent [expected_json], json_response
72 72 end
73 73  
74 74 should 'index action returns an json with node undetermined if the node is in the parent nodes list' do
... ... @@ -84,7 +84,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
84 84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'})
85 85 expected_json['children'] = []
86 86  
87   - assert_equal [expected_json], json_response
  87 + assert_equivalent [expected_json], json_response
88 88 end
89 89  
90 90 should 'index action returns an json with node closed if the node has article with children' do
... ... @@ -99,7 +99,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
99 99 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
100 100 expected_json['state'] = 'closed'
101 101  
102   - assert_equal [expected_json], json_response
  102 + assert_equivalent [expected_json], json_response
103 103 end
104 104  
105 105 should 'index action returns an json with all the children nodes if some parent is in the parents list' do
... ... @@ -122,7 +122,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
122 122 expected_json['children'] = children
123 123 expected_json['state'] = 'closed'
124 124  
125   - assert_equal [expected_json], json_response
  125 + assert_equivalent [expected_json], json_response
126 126 end
127 127  
128 128 should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do
... ... @@ -152,7 +152,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
152 152 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
153 153 expected_json.push(value)
154 154  
155   - assert_equal expected_json, json_response
  155 + assert_equivalent expected_json, json_response
156 156 end
157 157  
158 158 should 'index action returns an json without children nodes if the parent is not in the parents list' do
... ... @@ -174,7 +174,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
174 174 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
175 175 expected_json.push(value)
176 176  
177   - assert_equal expected_json, json_response
  177 + assert_equivalent expected_json, json_response
178 178 end
179 179  
180 180 end
... ...
plugins/foo/lib/ext/profile.rb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +require_dependency 'profile'
  2 +
  3 +Profile.class_eval do
  4 + def bar
  5 + end
  6 +end
... ...
plugins/foo/lib/foo_plugin.rb
1   -require_dependency 'foo_plugin/ext/profile'
2   -
3 1 class FooPlugin < Noosfero::Plugin
4 2  
5 3 def self.plugin_name
... ...
plugins/foo/lib/foo_plugin/ext/profile.rb
... ... @@ -1,6 +0,0 @@
1   -require_dependency 'profile'
2   -
3   -Profile.class_eval do
4   - def bar
5   - end
6   -end
plugins/google_analytics/lib/google_analytics_plugin.rb
1   -require_dependency File.dirname(__FILE__) + '/ext/profile'
2   -
3 1 class GoogleAnalyticsPlugin < Noosfero::Plugin
4 2  
5 3 include ActionView::Helpers::JavaScriptHelper
... ...
plugins/ldap/dependencies.rb
  1 +require 'rubygems'
1 2 require 'net/ldap'
... ...
plugins/ldap/install.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +system "gem install --user-install net-ldap -v 0.3.1"
  2 +puts "\nWARNING: This plugin is not setting up a ldap test server automatically.
  3 +Some tests may not be running. If you want to fully test this plugin, please
  4 +setup the ldap test server and make the proper configurations on
  5 +fixtures/ldap.yml.\n\n"
... ...
plugins/ldap/lib/ldap_plugin.rb
1   -require_dependency File.dirname(__FILE__) + '/ext/environment'
2 1 require File.dirname(__FILE__) + '/ldap_authentication.rb'
3 2  
4   -
5 3 class LdapPlugin < Noosfero::Plugin
6 4  
7 5 def self.plugin_name
... ...
plugins/mezuro/install.rb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +raise "Not ready yet"
... ...
plugins/pg_search/lib/pg_search_plugin.rb
1   -require 'ext/active_record'
2   -
3 1 class PgSearchPlugin < Noosfero::Plugin
4 2  
5 3 def self.plugin_name
... ...
plugins/require_auth_to_comment/lib/ext/profile.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +require_dependency 'profile'
  2 +
  3 +class Profile
  4 + settings_items :allow_unauthenticated_comments, :type => :boolean
  5 +end
... ...
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
1   -require_dependency 'require_auth_to_comment_plugin/ext/profile'
2   -
3 1 class RequireAuthToCommentPlugin < Noosfero::Plugin
4 2  
5 3 include ActionView::Helpers::TagHelper
... ...
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin/ext/profile.rb
... ... @@ -1,5 +0,0 @@
1   -require_dependency 'profile'
2   -
3   -class Profile
4   - settings_items :allow_unauthenticated_comments, :type => :boolean
5   -end
plugins/send_email/features/send_email_plugin.feature
... ... @@ -7,7 +7,7 @@ Feature: send_email_plugin
7 7 And I am logged in as "joaosilva"
8 8  
9 9 Scenario: expand macro in article content
10   - Given plugin SendEmailPlugin is enabled on environment
  10 + Given plugin SendEmail is enabled on environment
11 11 And the following articles
12 12 | owner | name | body |
13 13 | joaosilva | sample-article | URL path to {sendemail} action |
... ... @@ -15,7 +15,7 @@ Feature: send_email_plugin
15 15 Then I should see "URL path to /profile/joaosilva/plugin/send_email/deliver action"
16 16  
17 17 Scenario: expand macro in block content
18   - Given plugin SendEmailPlugin is enabled on environment
  18 + Given plugin SendEmail is enabled on environment
19 19 And the following blocks
20 20 | owner | type | html |
21 21 | joaosilva | RawHTMLBlock | URL path to {sendemail} action |
... ...
plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb
... ... @@ -63,6 +63,7 @@ class ShoppingCartPluginMyprofileController &lt; MyProfileController
63 63  
64 64 def treat_delivery_options(params)
65 65 result = {}
  66 + return result if params.nil? || params[:delivery_options].nil?
66 67 params[:options].size.times do |counter|
67 68 if params[:options][counter].present? && params[:prices][counter].present?
68 69 result[params[:options][counter]] = params[:prices][counter]
... ...
plugins/shopping_cart/lib/ext/enterprise.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +require_dependency 'enterprise'
  2 +
  3 +class Enterprise
  4 + has_many :orders, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'seller_id'
  5 +end
... ...
plugins/shopping_cart/lib/ext/person.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +require_dependency 'person'
  2 +
  3 +class Person
  4 + has_many :purchases, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'customer_id'
  5 +end
... ...
plugins/shopping_cart/lib/shopping_cart_plugin.rb
1   -require_dependency 'shopping_cart_plugin/ext/enterprise'
2   -require_dependency 'shopping_cart_plugin/ext/person'
3   -
4 1 class ShoppingCartPlugin < Noosfero::Plugin
5 2  
6 3 class << self
... ...
plugins/shopping_cart/lib/shopping_cart_plugin/ext/enterprise.rb
... ... @@ -1,5 +0,0 @@
1   -require_dependency 'enterprise'
2   -
3   -class Enterprise
4   - has_many :orders, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'seller_id'
5   -end
plugins/shopping_cart/lib/shopping_cart_plugin/ext/person.rb
... ... @@ -1,5 +0,0 @@
1   -require_dependency 'person'
2   -
3   -class Person
4   - has_many :purchases, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'customer_id'
5   -end
plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
... ... @@ -38,7 +38,7 @@ class ShoppingCartPlugin::CartHelperTest &lt; ActiveSupport::TestCase
38 38 value = 13.7
39 39 environment = Environment.default
40 40  
41   - assert_equal "#{environment.currency_unit} 13#{environment.currency_separator}70", float_to_currency_cart(value,environment)
  41 + assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment)
42 42 end
43 43  
44 44 end
... ...
plugins/shopping_cart/test/unit/shopping_cart_plugin_test.rb
... ... @@ -19,10 +19,9 @@ class ShoppingCartPluginTest &lt; ActiveSupport::TestCase
19 19 end
20 20  
21 21 should 'not add button if product unavailable' do
22   - product = fast_create(Product, :available => false)
23   - enterprise = mock()
  22 + enterprise = fast_create(:enterprise)
  23 + product = fast_create(Product, :available => false, :enterprise_id => enterprise.id)
24 24 enterprise.stubs(:shopping_cart).returns(true)
25   - product.stubs(:enterprise).returns(enterprise)
26 25  
27 26 assert_nil shopping_cart.add_to_cart_button(product)
28 27 end
... ...
plugins/solr/features/.search_products.feature.swp
No preview for this file type
plugins/solr/features/search_contents.feature
... ... @@ -5,6 +5,7 @@ Feature: search contents
5 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And the following users
9 10 Given the following users
10 11 | login | name |
... ...
plugins/solr/features/search_enterprises.feature
... ... @@ -5,6 +5,7 @@ Feature: search enterprises
5 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And the following enterprises
9 10 | identifier | name | img |
10 11 | shop1 | Shoes shop | shoes |
... ... @@ -12,6 +13,7 @@ Feature: search enterprises
12 13 And the following categories as facets
13 14 | name |
14 15 | Temáticas |
  16 +
15 17 Scenario: see default facets when searching
16 18 When I go to the search enterprises page
17 19 And I fill in "search-input" with "shoes"
... ... @@ -34,10 +36,10 @@ Feature: search enterprises
34 36 When I go to the search enterprises page
35 37 And I fill in "search-input" with "Artesanato"
36 38 And I press "Search"
37   - Then I should see "Pres. Prudente" within "#facet-menu-f_region"
38   - And I should see ", SP" within "#facet-menu-f_region"
39   - And I should see "City" within ".search-enterprise-region-label"
40   - And I should see "Pres. Prudente, SP" within ".search-enterprise-region-name"
  39 + Then I should see "Pres. Prudente" within "#facet-menu-solr_plugin_f_region"
  40 + And I should see ", SP" within "#facet-menu-solr_plugin_f_region"
  41 + And I should see "City" within ".facet-menu-label"
  42 + And I should see "Pres. Prudente, SP" within ".facet-menu-item"
41 43  
42 44 Scenario: find enterprise by region
43 45 Given the following cities
... ...
plugins/solr/features/search_people.feature
... ... @@ -5,6 +5,7 @@ Feature: search people
5 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And the following users
9 10 | login | name |
10 11 | joaosilva | Joao Silva |
... ...
plugins/solr/features/search_products.feature
... ... @@ -5,6 +5,7 @@ Feature: search products
5 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And feature "disable_asset_products" is disabled on environment
9 10 And the following enterprises
10 11 | identifier | name |
... ...
plugins/solr/features/step_definitions/solr_steps.rb
... ... @@ -13,6 +13,6 @@ Given /^the following categories as facets$/ do |table|
13 13 ids << cat.id
14 14 end
15 15 env = Environment.default
16   - env.top_level_category_as_facet_ids = ids
  16 + env.solr_plugin_top_level_category_as_facet_ids = ids
17 17 env.save!
18 18 end
... ...
plugins/solr/install.rb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +raise "Not ready yet. Some tests are failing."
  2 +require 'rubygems'
  3 +require 'rake'
  4 +
  5 +tasks_dir = File.join(File.dirname(__FILE__), 'vendor', 'plugins', 'acts_as_solr_reloaded', 'lib', 'tasks', '*.rake')
  6 +
  7 +Dir[tasks_dir].each do |file|
  8 + load file
  9 +end
  10 +
  11 +begin
  12 + Rake::Task['solr:download'].invoke
  13 +rescue Exception => exception
  14 +end
... ...
plugins/solr/lib/.solr_plugin.rb.swp
No preview for this file type
plugins/solr/lib/solr_plugin.rb
... ... @@ -6,8 +6,6 @@ class SolrPlugin &lt; Noosfero::Plugin
6 6  
7 7 include SolrPlugin::SearchHelper
8 8  
9   - delegate :params, :current_user, :to => :context
10   -
11 9 def self.plugin_name
12 10 "Solr"
13 11 end
... ... @@ -28,11 +26,16 @@ class SolrPlugin &lt; Noosfero::Plugin
28 26 return if empty_query?(query, category) && klass != Product
29 27  
30 28 solr_options = solr_options(class_asset(klass), category)
31   - user = context.send(:logged_in?) ? context.send(:user) : nil
32 29 solr_options.merge!(products_options(user)) if klass == Product && empty_query?(query, category)
33 30 klass.find_by_contents(query, paginate_options, solr_options.merge(options))
34 31 end
35 32  
36   -end
  33 + def method_missing method, *args, &block
  34 + if self.context.respond_to? method
  35 + self.context.send method, *args, &block
  36 + else
  37 + super method, *args, &block
  38 + end
  39 + end
37 40  
38   -Dir[File.join(SolrPlugin.root_path, 'lib', 'ext', '*.rb')].each {|file| require_dependency file }
  41 +end
... ...
plugins/solr/lib/solr_plugin/.search_helper.rb.swp
No preview for this file type
plugins/solr/lib/solr_plugin/search_helper.rb
... ... @@ -54,7 +54,7 @@ module SolrPlugin::SearchHelper
54 54 end
55 55  
56 56 def results_only?
57   - context.params[:action] == 'index'
  57 + params[:action] == 'index'
58 58 end
59 59  
60 60 def empty_query?(query, category)
... ... @@ -84,18 +84,18 @@ module SolrPlugin::SearchHelper
84 84 solr_options = {}
85 85 if !multiple_search?
86 86 if !results_only? and asset_class.respond_to? :facets
87   - solr_options.merge! asset_class.facets_find_options(context.params[:facet])
  87 + solr_options.merge! asset_class.facets_find_options(params[:facet])
88 88 solr_options[:all_facets] = true
89 89 end
90 90 solr_options[:filter_queries] ||= []
91 91 solr_options[:filter_queries] += filters(asset)
92   - solr_options[:filter_queries] << "environment_id:#{context.environment.id}"
  92 + solr_options[:filter_queries] << "environment_id:#{environment.id}"
93 93 solr_options[:filter_queries] << asset_class.facet_category_query.call(category) if category
94 94  
95 95 solr_options[:boost_functions] ||= []
96   - context.params[:order_by] = nil if context.params[:order_by] == 'none'
97   - if context.params[:order_by]
98   - order = SortOptions[asset][context.params[:order_by].to_sym]
  96 + params[:order_by] = nil if params[:order_by] == 'none'
  97 + if params[:order_by]
  98 + order = SortOptions[asset][params[:order_by].to_sym]
99 99 raise "Unknown order by" if order.nil?
100 100 order[:solr_opts].each do |opt, value|
101 101 solr_options[opt] = value.is_a?(Proc) ? instance_eval(&value) : value
... ...
plugins/solr/public/style.css
1 1 .controller-search #search-column-right .search-field .formfield {
2 2 width: 594px;
3   - display: inline-block;
  3 + display: inline;
4 4 }
5 5  
6 6 #search-column-right .search-customize-options {
7   - position: absolute;
8 7 margin: 0;
9 8 padding: 5px 0;
10   - bottom: 0;
11   - left: 0;
12 9 }
13 10  
14 11 #search-column-right .search-results-box .vcard {
... ...