Commit b397fec9359cfaffa79f05006ae5852947cb7f86
Exists in
master
and in
29 other branches
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,6 +44,7 @@ Antonio Terceiro <terceiro@colivre.coop.br> | ||
44 | Aurelio A. Heckert <aurelio@colivre.coop.br> | 44 | Aurelio A. Heckert <aurelio@colivre.coop.br> |
45 | Braulio Bhavamitra <brauliobo@gmail.com> | 45 | Braulio Bhavamitra <brauliobo@gmail.com> |
46 | Bráulio Bhavamitra <brauliobo@gmail.com> | 46 | Bráulio Bhavamitra <brauliobo@gmail.com> |
47 | +Braulio Bhavamitra <braulio@eita.org.br> | ||
47 | Caio <caio.csalgado@gmail.com> | 48 | Caio <caio.csalgado@gmail.com> |
48 | Caio + Diego + Pedro + João <caio.csalgado@gmail.com> | 49 | Caio + Diego + Pedro + João <caio.csalgado@gmail.com> |
49 | Caio Formiga <caio.formiga@gmail.com> | 50 | Caio Formiga <caio.formiga@gmail.com> |
@@ -147,6 +148,7 @@ João M. M. Silva + Rafael Manzo <jaodsilv@linux.ime.usp.br> | @@ -147,6 +148,7 @@ João M. M. Silva + Rafael Manzo <jaodsilv@linux.ime.usp.br> | ||
147 | João M. M. Silva + Renan Teruo <jaodsilv@linux.ime.usp.br> | 148 | João M. M. Silva + Renan Teruo <jaodsilv@linux.ime.usp.br> |
148 | Joenio Costa <joenio@colivre.coop.br> | 149 | Joenio Costa <joenio@colivre.coop.br> |
149 | Josef Spillner <josef.spillner@tu-dresden.de> | 150 | Josef Spillner <josef.spillner@tu-dresden.de> |
151 | +Junior Silva <juniorsilva7@juniorsilva-Aspire-5750Z.(none)> | ||
150 | Keilla Menezes <keilla@colivre.coop.br> | 152 | Keilla Menezes <keilla@colivre.coop.br> |
151 | Larissa Reis <larissa@colivre.coop.br> | 153 | Larissa Reis <larissa@colivre.coop.br> |
152 | Larissa Reis <reiss.larissa@gmail.com> | 154 | Larissa Reis <reiss.larissa@gmail.com> |
app/controllers/my_profile/manage_products_controller.rb
@@ -6,10 +6,10 @@ class ManageProductsController < ApplicationController | @@ -6,10 +6,10 @@ class ManageProductsController < ApplicationController | ||
6 | before_filter :login_required, :except => [:show] | 6 | before_filter :login_required, :except => [:show] |
7 | before_filter :create_product?, :only => [:new] | 7 | before_filter :create_product?, :only => [:new] |
8 | 8 | ||
9 | - protected | 9 | + protected |
10 | 10 | ||
11 | def check_environment_feature | 11 | def check_environment_feature |
12 | - if profile.environment.enabled?('disable_products_for_enterprises') | 12 | + unless profile.environment.enabled?('products_for_enterprises') |
13 | render_not_found | 13 | render_not_found |
14 | return | 14 | return |
15 | end | 15 | end |
app/controllers/my_profile/profile_design_controller.rb
@@ -38,7 +38,7 @@ class ProfileDesignController < BoxOrganizerController | @@ -38,7 +38,7 @@ class ProfileDesignController < BoxOrganizerController | ||
38 | end | 38 | end |
39 | 39 | ||
40 | # product block exclusive for enterprises in environments that permits it | 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 | blocks << ProductsBlock | 42 | blocks << ProductsBlock |
43 | end | 43 | end |
44 | 44 |
app/controllers/public/catalog_controller.rb
@@ -12,7 +12,7 @@ class CatalogController < PublicController | @@ -12,7 +12,7 @@ class CatalogController < PublicController | ||
12 | protected | 12 | protected |
13 | 13 | ||
14 | def check_enterprise_and_environment | 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 | redirect_to :controller => 'profile', :profile => profile.identifier, :action => 'index' | 16 | redirect_to :controller => 'profile', :profile => profile.identifier, :action => 'index' |
17 | end | 17 | end |
18 | end | 18 | end |
app/helpers/boxes_helper.rb
@@ -99,9 +99,11 @@ module BoxesHelper | @@ -99,9 +99,11 @@ module BoxesHelper | ||
99 | unless block.visible? | 99 | unless block.visible? |
100 | options[:title] = _("This block is invisible. Your visitors will not see it.") | 100 | options[:title] = _("This block is invisible. Your visitors will not see it.") |
101 | end | 101 | end |
102 | + | ||
102 | if @controller.send(:content_editor?) | 103 | if @controller.send(:content_editor?) |
103 | result = filter_html(result, block) | 104 | result = filter_html(result, block) |
104 | end | 105 | end |
106 | + | ||
105 | box_decorator.block_target(block.box, block) + | 107 | box_decorator.block_target(block.box, block) + |
106 | content_tag('div', | 108 | content_tag('div', |
107 | content_tag('div', | 109 | content_tag('div', |
app/helpers/cms_helper.rb
@@ -28,7 +28,7 @@ module CmsHelper | @@ -28,7 +28,7 @@ module CmsHelper | ||
28 | end | 28 | end |
29 | 29 | ||
30 | def link_to_article(article) | 30 | def link_to_article(article) |
31 | - article_name = short_filename(article.title, 30) | 31 | + article_name = article.title |
32 | if article.folder? | 32 | if article.folder? |
33 | link_to article_name, {:action => 'view', :id => article.id}, :class => icon_for_article(article) | 33 | link_to article_name, {:action => 'view', :id => article.id}, :class => icon_for_article(article) |
34 | else | 34 | else |
app/helpers/profile_editor_helper.rb
@@ -136,7 +136,7 @@ module ProfileEditorHelper | @@ -136,7 +136,7 @@ module ProfileEditorHelper | ||
136 | concat( | 136 | concat( |
137 | content_tag( | 137 | content_tag( |
138 | 'div', | 138 | 'div', |
139 | - capture(&block) + content_tag('br', '', :style => 'clear: left'), | 139 | + capture(&block) + tag('br', :style => 'clear: left'), |
140 | :class => 'control-panel') | 140 | :class => 'control-panel') |
141 | ) | 141 | ) |
142 | end | 142 | end |
app/helpers/profile_helper.rb
1 | module ProfileHelper | 1 | module ProfileHelper |
2 | 2 | ||
3 | def display_field(title, profile, field, force = false) | 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 | return '' | 5 | return '' |
7 | end | 6 | end |
8 | value = profile.send(field) | 7 | value = profile.send(field) |
app/models/action_tracker_notification.rb
@@ -3,7 +3,7 @@ class ActionTrackerNotification < ActiveRecord::Base | @@ -3,7 +3,7 @@ class ActionTrackerNotification < ActiveRecord::Base | ||
3 | belongs_to :profile | 3 | belongs_to :profile |
4 | belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id' | 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 | validates_presence_of :profile_id, :action_tracker_id | 8 | validates_presence_of :profile_id, :action_tracker_id |
9 | validates_uniqueness_of :action_tracker_id, :scope => :profile_id | 9 | validates_uniqueness_of :action_tracker_id, :scope => :profile_id |
app/models/article.rb
@@ -57,7 +57,7 @@ class Article < ActiveRecord::Base | @@ -57,7 +57,7 @@ class Article < ActiveRecord::Base | ||
57 | has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ] | 57 | has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ] |
58 | has_many :categories, :through => :article_categorizations | 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 | has_many :categories_including_virtual, :through => :article_categorizations_including_virtual, :source => :category | 61 | has_many :categories_including_virtual, :through => :article_categorizations_including_virtual, :source => :category |
62 | 62 | ||
63 | acts_as_having_settings :field => :setting | 63 | acts_as_having_settings :field => :setting |
app/models/category.rb
@@ -22,23 +22,15 @@ class Category < ActiveRecord::Base | @@ -22,23 +22,15 @@ class Category < ActiveRecord::Base | ||
22 | 22 | ||
23 | named_scope :on_level, lambda { |parent| {:conditions => {:parent_id => parent}} } | 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 | acts_as_filesystem | 25 | acts_as_filesystem |
34 | 26 | ||
35 | - has_many :article_categorizations, :dependent => :destroy | 27 | + has_many :article_categorizations |
36 | has_many :articles, :through => :article_categorizations | 28 | has_many :articles, :through => :article_categorizations |
37 | has_many :comments, :through => :articles | 29 | has_many :comments, :through => :articles |
38 | 30 | ||
39 | has_many :events, :through => :article_categorizations, :class_name => 'Event', :source => :article | 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 | has_many :profiles, :through => :profile_categorizations, :source => :profile | 34 | has_many :profiles, :through => :profile_categorizations, :source => :profile |
43 | has_many :enterprises, :through => :profile_categorizations, :source => :profile, :class_name => 'Enterprise' | 35 | has_many :enterprises, :through => :profile_categorizations, :source => :profile, :class_name => 'Enterprise' |
44 | has_many :people, :through => :profile_categorizations, :source => :profile, :class_name => 'Person' | 36 | has_many :people, :through => :profile_categorizations, :source => :profile, :class_name => 'Person' |
app/models/enterprise.rb
@@ -134,7 +134,7 @@ class Enterprise < Organization | @@ -134,7 +134,7 @@ class Enterprise < Organization | ||
134 | [ProfileImageBlock.new, LinkListBlock.new(:links => links)], | 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 | blocks[2].unshift ProductsBlock.new | 138 | blocks[2].unshift ProductsBlock.new |
139 | end | 139 | end |
140 | blocks | 140 | blocks |
app/models/environment.rb
@@ -95,7 +95,6 @@ class Environment < ActiveRecord::Base | @@ -95,7 +95,6 @@ class Environment < ActiveRecord::Base | ||
95 | 'disable_asset_communities' => __('Disable search for communities'), | 95 | 'disable_asset_communities' => __('Disable search for communities'), |
96 | 'disable_asset_products' => _('Disable search for products'), | 96 | 'disable_asset_products' => _('Disable search for products'), |
97 | 'disable_asset_events' => _('Disable search for events'), | 97 | 'disable_asset_events' => _('Disable search for events'), |
98 | - 'disable_products_for_enterprises' => __('Disable products for enterprises'), | ||
99 | 'disable_categories' => _('Disable categories'), | 98 | 'disable_categories' => _('Disable categories'), |
100 | 'disable_header_and_footer' => _('Disable header/footer editing by users'), | 99 | 'disable_header_and_footer' => _('Disable header/footer editing by users'), |
101 | 'disable_gender_icon' => _('Disable gender icon'), | 100 | 'disable_gender_icon' => _('Disable gender icon'), |
@@ -103,9 +102,13 @@ class Environment < ActiveRecord::Base | @@ -103,9 +102,13 @@ class Environment < ActiveRecord::Base | ||
103 | 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), | 102 | 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), |
104 | 'disable_contact_person' => _('Disable contact for people'), | 103 | 'disable_contact_person' => _('Disable contact for people'), |
105 | 'disable_contact_community' => _('Disable contact for groups/communities'), | 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 | 'enterprise_activation' => __('Enable activation of enterprises'), | 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 | 'media_panel' => _('Media panel in WYSIWYG editor'), | 112 | 'media_panel' => _('Media panel in WYSIWYG editor'), |
110 | 'select_preferred_domain' => _('Select preferred domains per profile'), | 113 | 'select_preferred_domain' => _('Select preferred domains per profile'), |
111 | 'use_portal_community' => _('Use the portal as news source for front page'), | 114 | 'use_portal_community' => _('Use the portal as news source for front page'), |
@@ -118,8 +121,6 @@ class Environment < ActiveRecord::Base | @@ -118,8 +121,6 @@ class Environment < ActiveRecord::Base | ||
118 | 'organizations_are_moderated_by_default' => _("Organizations have moderated publication by default"), | 121 | 'organizations_are_moderated_by_default' => _("Organizations have moderated publication by default"), |
119 | 'enable_organization_url_change' => _("Allow organizations to change their URL"), | 122 | 'enable_organization_url_change' => _("Allow organizations to change their URL"), |
120 | 'admin_must_approve_new_communities' => _("Admin must approve creation of communities"), | 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 | 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'), | 124 | 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'), |
124 | 'xmpp_chat' => _('XMPP/Jabber based chat'), | 125 | 'xmpp_chat' => _('XMPP/Jabber based chat'), |
125 | 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'), | 126 | 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'), |
@@ -281,8 +282,9 @@ class Environment < ActiveRecord::Base | @@ -281,8 +282,9 @@ class Environment < ActiveRecord::Base | ||
281 | end | 282 | end |
282 | 283 | ||
283 | # Enables a feature identified by its name | 284 | # Enables a feature identified by its name |
284 | - def enable(feature) | 285 | + def enable(feature, must_save=true) |
285 | self.settings["#{feature}_enabled".to_sym] = true | 286 | self.settings["#{feature}_enabled".to_sym] = true |
287 | + self.save! if must_save | ||
286 | end | 288 | end |
287 | 289 | ||
288 | def enable_plugin(plugin) | 290 | def enable_plugin(plugin) |
@@ -292,8 +294,9 @@ class Environment < ActiveRecord::Base | @@ -292,8 +294,9 @@ class Environment < ActiveRecord::Base | ||
292 | end | 294 | end |
293 | 295 | ||
294 | # Disables a feature identified by its name | 296 | # Disables a feature identified by its name |
295 | - def disable(feature) | 297 | + def disable(feature, must_save=true) |
296 | self.settings["#{feature}_enabled".to_sym] = false | 298 | self.settings["#{feature}_enabled".to_sym] = false |
299 | + self.save! if must_save | ||
297 | end | 300 | end |
298 | 301 | ||
299 | def disable_plugin(plugin) | 302 | def disable_plugin(plugin) |
@@ -337,7 +340,7 @@ class Environment < ActiveRecord::Base | @@ -337,7 +340,7 @@ class Environment < ActiveRecord::Base | ||
337 | %w( | 340 | %w( |
338 | disable_asset_products | 341 | disable_asset_products |
339 | disable_gender_icon | 342 | disable_gender_icon |
340 | - disable_products_for_enterprises | 343 | + products_for_enterprises |
341 | disable_select_city_for_contact | 344 | disable_select_city_for_contact |
342 | enterprise_registration | 345 | enterprise_registration |
343 | media_panel | 346 | media_panel |
@@ -345,7 +348,7 @@ class Environment < ActiveRecord::Base | @@ -345,7 +348,7 @@ class Environment < ActiveRecord::Base | ||
345 | show_balloon_with_profile_links_when_clicked | 348 | show_balloon_with_profile_links_when_clicked |
346 | use_portal_community | 349 | use_portal_community |
347 | ).each do |feature| | 350 | ).each do |feature| |
348 | - enable(feature) | 351 | + enable(feature, false) |
349 | end | 352 | end |
350 | end | 353 | end |
351 | 354 |
app/models/featured_products_block.rb
@@ -7,8 +7,9 @@ class FeaturedProductsBlock < Block | @@ -7,8 +7,9 @@ class FeaturedProductsBlock < Block | ||
7 | 7 | ||
8 | before_save do |block| | 8 | before_save do |block| |
9 | if block.owner.kind_of?(Environment) && block.product_ids.blank? | 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 | end | 13 | end |
13 | block.groups_of = block.groups_of.to_i | 14 | block.groups_of = block.groups_of.to_i |
14 | end | 15 | end |
app/models/person.rb
@@ -471,8 +471,9 @@ class Person < Profile | @@ -471,8 +471,9 @@ class Person < Profile | ||
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") | 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 | end | 472 | end |
473 | 473 | ||
474 | + # by default, all fields are private | ||
474 | def public_fields | 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 | end | 477 | end |
477 | 478 | ||
478 | protected | 479 | protected |
app/models/price_detail.rb
@@ -4,11 +4,11 @@ class PriceDetail < ActiveRecord::Base | @@ -4,11 +4,11 @@ class PriceDetail < ActiveRecord::Base | ||
4 | validates_presence_of :product_id | 4 | validates_presence_of :product_id |
5 | 5 | ||
6 | belongs_to :production_cost | 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 | validates_uniqueness_of :production_cost_id, :scope => :product_id | 8 | validates_uniqueness_of :production_cost_id, :scope => :product_id |
9 | 9 | ||
10 | def name | 10 | def name |
11 | - production_cost.name | 11 | + production_cost.nil? ? _('Other costs') : production_cost.name |
12 | end | 12 | end |
13 | 13 | ||
14 | def price | 14 | def price |
app/models/product.rb
@@ -191,11 +191,13 @@ class Product < ActiveRecord::Base | @@ -191,11 +191,13 @@ class Product < ActiveRecord::Base | ||
191 | (price - total_production_cost.to_f).zero? | 191 | (price - total_production_cost.to_f).zero? |
192 | end | 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 | end | 198 | end |
199 | + reload # to remove temporary duplicated price_details | ||
200 | + price_details | ||
199 | end | 201 | end |
200 | 202 | ||
201 | def price_description_percentage | 203 | def price_description_percentage |
app/models/profile.rb
@@ -226,12 +226,14 @@ class Profile < ActiveRecord::Base | @@ -226,12 +226,14 @@ class Profile < ActiveRecord::Base | ||
226 | 226 | ||
227 | belongs_to :region | 227 | belongs_to :region |
228 | 228 | ||
229 | + LOCATION_FIELDS = %w[address district city state country_name zip_code] | ||
230 | + | ||
229 | def location(separator = ' - ') | 231 | def location(separator = ' - ') |
230 | myregion = self.region | 232 | myregion = self.region |
231 | if myregion | 233 | if myregion |
232 | myregion.hierarchy.reverse.first(2).map(&:name).join(separator) | 234 | myregion.hierarchy.reverse.first(2).map(&:name).join(separator) |
233 | else | 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 | end | 237 | end |
236 | end | 238 | end |
237 | 239 | ||
@@ -882,6 +884,21 @@ private :generate_url, :url_options | @@ -882,6 +884,21 @@ private :generate_url, :url_options | ||
882 | [] | 884 | [] |
883 | end | 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 | # field => privacy (e.g.: "address" => "public") | 902 | # field => privacy (e.g.: "address" => "public") |
886 | def fields_privacy | 903 | def fields_privacy |
887 | self.data[:fields_privacy] | 904 | self.data[:fields_privacy] |
app/models/profile_list_block.rb
@@ -54,7 +54,7 @@ class ProfileListBlock < Block | @@ -54,7 +54,7 @@ class ProfileListBlock < Block | ||
54 | list = content_tag 'ul', nl +' '+ list + nl | 54 | list = content_tag 'ul', nl +' '+ list + nl |
55 | end | 55 | end |
56 | block_title(title) + nl + | 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 | end | 58 | end |
59 | end | 59 | end |
60 | 60 |
app/models/region.rb
@@ -8,9 +8,9 @@ class Region < Category | @@ -8,9 +8,9 @@ class Region < Category | ||
8 | validators.count > 0 | 8 | validators.count > 0 |
9 | end | 9 | end |
10 | 10 | ||
11 | - named_scope :with_validators, :group => 'id', | 11 | + named_scope :with_validators, :select => 'DISTINCT ON (categories.id) *', |
12 | :joins => 'INNER JOIN region_validators on (region_validators.region_id = categories.id)' | 12 | :joins => 'INNER JOIN region_validators on (region_validators.region_id = categories.id)' |
13 | - | 13 | + |
14 | end | 14 | end |
15 | 15 | ||
16 | require_dependency 'city' | 16 | require_dependency 'city' |
app/sweepers/profile_sweeper.rb
@@ -4,7 +4,7 @@ class ProfileSweeper # < ActiveRecord::Observer | @@ -4,7 +4,7 @@ class ProfileSweeper # < ActiveRecord::Observer | ||
4 | include SweeperHelper | 4 | include SweeperHelper |
5 | 5 | ||
6 | def after_update(profile) | 6 | def after_update(profile) |
7 | - expire_caches(profile) | 7 | + self.delay.expire_caches profile |
8 | end | 8 | end |
9 | 9 | ||
10 | def after_create(profile) | 10 | def after_create(profile) |
app/views/blocks/profile_info.rhtml
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | <ul class="profile-info-data" id="profile-info-data-<%= block.id %>"> | 17 | <ul class="profile-info-data" id="profile-info-data-<%= block.id %>"> |
18 | <li><%= link_to __('Homepage'), block.owner.url, :class => 'url' %></li> | 18 | <li><%= link_to __('Homepage'), block.owner.url, :class => 'url' %></li> |
19 | <li><%= link_to _('View profile'), block.owner.public_profile_url %></li> | 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 | <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li> | 21 | <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li> |
22 | <% end %> | 22 | <% end %> |
23 | <li id="profile-admin-url-<%= block.id %>"></li> | 23 | <li id="profile-admin-url-<%= block.id %>"></li> |
app/views/cms/view.rhtml
app/views/content_viewer/_enterprise_homepage.rhtml
1 | <%= display_profile_info enterprise_homepage.profile %> | 1 | <%= display_profile_info enterprise_homepage.profile %> |
2 | <div><%= enterprise_homepage.body %></div> | 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,7 +10,7 @@ | ||
10 | </li> | 10 | </li> |
11 | <% @product.price_details.each do |price_detail| %> | 11 | <% @product.price_details.each do |price_detail| %> |
12 | <li> | 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 | <div class='price-detail-price'><%= float_to_currency(price_detail.price) %></div> | 14 | <div class='price-detail-price'><%= float_to_currency(price_detail.price) %></div> |
15 | </li> | 15 | </li> |
16 | <% end %> | 16 | <% end %> |
app/views/manage_products/_edit_price_details.rhtml
1 | <% price_details.each do |price_detail| %> | 1 | <% price_details.each do |price_detail| %> |
2 | <tr id='<%= "price-detail-#{price_detail.id}" %>'> | 2 | <tr id='<%= "price-detail-#{price_detail.id}" %>'> |
3 | <td><%= select_production_cost(@product, price_detail.production_cost_id) %></td> | 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 | <td> | 5 | <td> |
6 | <%= link_to_remote(_('Remove'), | 6 | <%= link_to_remote(_('Remove'), |
7 | :update => "price-detail-#{price_detail.id}", | 7 | :update => "price-detail-#{price_detail.id}", |
app/views/manage_products/_manage_product_details.rhtml
@@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
34 | <table id='new-cost-fields'> | 34 | <table id='new-cost-fields'> |
35 | <tr> | 35 | <tr> |
36 | <td><%= select_production_cost(@product) %></td> | 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 | <td><%= link_to(_('Cancel'), '#', {:class => 'cancel-new-cost'}) %></td> | 38 | <td><%= link_to(_('Cancel'), '#', {:class => 'cancel-new-cost'}) %></td> |
39 | </tr> | 39 | </tr> |
40 | </table> | 40 | </table> |
app/views/profile/_organization_profile.rhtml
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | <td><%= show_date(profile.created_at) %></td> | 19 | <td><%= show_date(profile.created_at) %></td> |
20 | </tr> | 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 | <tr> | 23 | <tr> |
24 | <td></td> | 24 | <td></td> |
25 | <td> | 25 | <td> |
app/views/profile/_person_profile.rhtml
@@ -18,18 +18,6 @@ | @@ -18,18 +18,6 @@ | ||
18 | <% cache_timeout(profile.relationships_cache_key, 4.hours) do %> | 18 | <% cache_timeout(profile.relationships_cache_key, 4.hours) do %> |
19 | <%= display_work_info profile %> | 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 | <tr> | 21 | <tr> |
34 | <th colspan='2'><%= _('Network')%></th> | 22 | <th colspan='2'><%= _('Network')%></th> |
35 | </tr> | 23 | </tr> |
@@ -41,6 +29,12 @@ | @@ -41,6 +29,12 @@ | ||
41 | <td><%= __('Communities') + ':' %></td> | 29 | <td><%= __('Communities') + ':' %></td> |
42 | <td><%= link_to profile.communities.count, :controller => "profile", :action => 'communities' %></td> | 30 | <td><%= link_to profile.communities.count, :controller => "profile", :action => 'communities' %></td> |
43 | </tr> | 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 | <%= render :partial => 'common' %> | 39 | <%= render :partial => 'common' %> |
46 | 40 |
app/views/profile_editor/index.rhtml
@@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
45 | 45 | ||
46 | <%= control_panel_button(_('Manage Members'), 'members', :controller => 'profile_members') if profile.organization? && user.has_permission?(:manage_memberships, profile) %> | 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 | <% if !environment.enabled?('disable_asset_enterprises') %> | 50 | <% if !environment.enabled?('disable_asset_enterprises') %> |
51 | <% if profile.is_validation_entity? %> | 51 | <% if profile.is_validation_entity? %> |
app/views/profile_members/_members_list.rhtml
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | <th><%= _('Actions') %></th> | 10 | <th><%= _('Actions') %></th> |
11 | </tr> | 11 | </tr> |
12 | <% collection.each do |m| %> | 12 | <% collection.each do |m| %> |
13 | - <tr> | 13 | + <tr title="<%= m.name %>"> |
14 | <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td> | 14 | <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td> |
15 | <td> | 15 | <td> |
16 | <div class="members-buttons-cell"> | 16 | <div class="members-buttons-cell"> |
app/views/search/_full_article.html.erb
1 | <li class="search-article-item article-item"> | 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 | <div class="search-content-first-column"> | 6 | <div class="search-content-first-column"> |
4 | <%= render :partial => 'image', :object => article %> | 7 | <%= render :partial => 'image', :object => article %> |
5 | </div> | 8 | </div> |
9 | + | ||
6 | <table class="noborder search-content-second-column"> | 10 | <table class="noborder search-content-second-column"> |
7 | <%= render :partial => 'article_common', :object => article %> | 11 | <%= render :partial => 'article_common', :object => article %> |
8 | </table> | 12 | </table> |
app/views/search/_full_blog.html.erb
1 | <li class="search-blog article-item"> | 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 | <div class="search-content-first-column"> | 6 | <div class="search-content-first-column"> |
4 | <%= render :partial => 'image', :object => blog %> | 7 | <%= render :partial => 'image', :object => blog %> |
5 | </div> | 8 | </div> |
9 | + | ||
6 | <table class="noborder search-content-second-column"> | 10 | <table class="noborder search-content-second-column"> |
7 | <tr class="search-blog-items"> | 11 | <tr class="search-blog-items"> |
8 | <td class="search-field-label"><%= _("Last posts") %></td> | 12 | <td class="search-field-label"><%= _("Last posts") %></td> |
app/views/search/_full_event.html.erb
1 | <li class="search-event-item article-item"> | 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 | </li> | 29 | </li> |
app/views/search/_full_folder.html.erb
1 | <li class="search-folder-item article-item"> | 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 | <div class="search-content-first-column"> | 6 | <div class="search-content-first-column"> |
4 | <%= render :partial => 'image', :object => folder %> | 7 | <%= render :partial => 'image', :object => folder %> |
5 | </div> | 8 | </div> |
9 | + | ||
6 | <table class="noborder search-content-second-column"> | 10 | <table class="noborder search-content-second-column"> |
7 | <tr class="search-folder-items"> | 11 | <tr class="search-folder-items"> |
8 | <td class="search-field-label"><%= _("Last items") %></td> | 12 | <td class="search-field-label"><%= _("Last items") %></td> |
app/views/search/_full_forum.html.erb
1 | <li class="search-forum-item article-item"> | 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 | <div class="search-content-first-column"> | 6 | <div class="search-content-first-column"> |
4 | <%= render :partial => 'image', :object => forum %> | 7 | <%= render :partial => 'image', :object => forum %> |
5 | </div> | 8 | </div> |
9 | + | ||
6 | <table class="noborder search-content-second-column"> | 10 | <table class="noborder search-content-second-column"> |
7 | <tr class="search-forum-items"> | 11 | <tr class="search-forum-items"> |
8 | <td class="search-field-label"><%= _("Last topics") %></td> | 12 | <td class="search-field-label"><%= _("Last topics") %></td> |
app/views/search/_full_gallery.html.erb
1 | <li class="search-gallery article-item"> | 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 | <div class="search-content-first-column"> | 6 | <div class="search-content-first-column"> |
4 | <%= render :partial => 'image', :object => gallery %> | 7 | <%= render :partial => 'image', :object => gallery %> |
5 | </div> | 8 | </div> |
9 | + | ||
6 | <table class="noborder search-content-second-column"> | 10 | <table class="noborder search-content-second-column"> |
7 | <%= render :partial => 'article_common', :object => gallery %> | 11 | <%= render :partial => 'article_common', :object => gallery %> |
8 | </table> | 12 | </table> |
app/views/search/_full_text_article.html.erb
1 | <li class="search-text-article-item article-item"> | 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 | <div class="search-content-first-column"> | 6 | <div class="search-content-first-column"> |
5 | <%= render :partial => 'image', :object => text_article %> | 7 | <%= render :partial => 'image', :object => text_article %> |
app/views/search/_full_uploaded_file.html.erb
1 | <li class="search-uploaded-file-item article-item"> | 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 | <div class="search-content-first-column"> | 6 | <div class="search-content-first-column"> |
5 | <%= render :partial => 'image', :object => uploaded_file %> | 7 | <%= render :partial => 'image', :object => uploaded_file %> |
app/views/shared/tiny_mce.rhtml
@@ -70,7 +70,7 @@ tinyMCE.init({ | @@ -70,7 +70,7 @@ tinyMCE.init({ | ||
70 | paste_insert_word_content_callback : "convertWord", | 70 | paste_insert_word_content_callback : "convertWord", |
71 | paste_use_dialog: false, | 71 | paste_use_dialog: false, |
72 | apply_source_formatting : true, | 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 | content_css: '/stylesheets/tinymce.css,<%= macro_css_files %>', | 74 | content_css: '/stylesheets/tinymce.css,<%= macro_css_files %>', |
75 | language: <%= tinymce_language.inspect %>, | 75 | language: <%= tinymce_language.inspect %>, |
76 | entity_encoding: 'raw', | 76 | entity_encoding: 'raw', |
config/environment.rb
@@ -85,10 +85,10 @@ Rails::Initializer.run do |config| | @@ -85,10 +85,10 @@ Rails::Initializer.run do |config| | ||
85 | } | 85 | } |
86 | 86 | ||
87 | # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper | 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 | # Adds custom tags to the Set of allowed html tags for the #sanitize helper | 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 | # See Rails::Configuration for more options | 93 | # See Rails::Configuration for more options |
94 | 94 |
db/migrate/20130529155000_rename_environment_setting_disable_products.rb
0 → 100644
@@ -0,0 +1,21 @@ | @@ -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 => 20130711213046) do | @@ -221,7 +221,6 @@ ActiveRecord::Schema.define(:version => 20130711213046) do | ||
221 | t.string "source_type" | 221 | t.string "source_type" |
222 | t.string "user_agent" | 222 | t.string "user_agent" |
223 | t.string "referrer" | 223 | t.string "referrer" |
224 | - t.integer "group_id" | ||
225 | end | 224 | end |
226 | 225 | ||
227 | add_index "comments", ["source_id", "spam"], :name => "index_comments_on_source_id_and_spam" | 226 | add_index "comments", ["source_id", "spam"], :name => "index_comments_on_source_id_and_spam" |
debian/changelog
features/edit_article.feature
@@ -64,8 +64,8 @@ Feature: edit article | @@ -64,8 +64,8 @@ Feature: edit article | ||
64 | And I fill in "Tag list" with "aurium, bug" | 64 | And I fill in "Tag list" with "aurium, bug" |
65 | And I press "Save" | 65 | And I press "Save" |
66 | And I go to /joaosilva/article-with-tags | 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 | Scenario: redirect to the created article | 70 | Scenario: redirect to the created article |
71 | Given I am on joaosilva's control panel | 71 | Given I am on joaosilva's control panel |
features/last_administrator_leaving.feature
@@ -17,7 +17,7 @@ Feature: remove administrator role | @@ -17,7 +17,7 @@ Feature: remove administrator role | ||
17 | Scenario: the last administrator removes his administrator role and must choose the new administrator | 17 | Scenario: the last administrator removes his administrator role and must choose the new administrator |
18 | Given "Maria Souza" is a member of "Nice people" | 18 | Given "Maria Souza" is a member of "Nice people" |
19 | And I am on Nice people's members management | 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 | And I uncheck "Profile Administrator" | 21 | And I uncheck "Profile Administrator" |
22 | When I press "Save changes" | 22 | When I press "Save changes" |
23 | Then I should see "Since you are the last administrator, you must choose" | 23 | Then I should see "Since you are the last administrator, you must choose" |
features/plugins.feature
@@ -22,27 +22,27 @@ Feature: plugins | @@ -22,27 +22,27 @@ Feature: plugins | ||
22 | | profile_tabs | lambda { {:title => 'Test plugin tab', :id => 'test_plugin', :content => lambda {'Test plugin random content'} } } | | 22 | | profile_tabs | lambda { {:title => 'Test plugin tab', :id => 'test_plugin', :content => lambda {'Test plugin random content'} } } | |
23 | 23 | ||
24 | Scenario: a user must see the plugin\'s button in the control panel if the plugin is enabled | 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 | And I go to joaosilva's control panel | 26 | And I go to joaosilva's control panel |
27 | Then I should see "Test plugin button" | 27 | Then I should see "Test plugin button" |
28 | 28 | ||
29 | Scenario: a user must see the plugin\'s tab in in the profile if the plugin is enabled | 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 | And I am on joaosilva's profile | 31 | And I am on joaosilva's profile |
32 | Then I should see "Test plugin tab" | 32 | Then I should see "Test plugin tab" |
33 | 33 | ||
34 | Scenario: a user must not see the plugin\'s button in the control panel if the plugin is disabled | 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 | And I go to joaosilva's control panel | 36 | And I go to joaosilva's control panel |
37 | Then I should not see "Test plugin button" | 37 | Then I should not see "Test plugin button" |
38 | 38 | ||
39 | Scenario: a user must not see the plugin\'s tab in in the profile if the plugin is disabled | 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 | And I am on joaosilva's profile | 41 | And I am on joaosilva's profile |
42 | Then I should not see "Test plugin tab" | 42 | Then I should not see "Test plugin tab" |
43 | 43 | ||
44 | Scenario: an admin should be able to deactivate a plugin | 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 | And I am logged in as admin | 46 | And I am logged in as admin |
47 | When I go to admin_user's control panel | 47 | When I go to admin_user's control panel |
48 | Then I should see "Test plugin button" | 48 | Then I should see "Test plugin button" |
features/search_communities.feature
@@ -4,7 +4,8 @@ Feature: search communities | @@ -4,7 +4,8 @@ Feature: search communities | ||
4 | In order to find ones that interest me | 4 | In order to find ones that interest me |
5 | 5 | ||
6 | Background: | 6 | Background: |
7 | - Given the following category | 7 | + Given plugin Solr is enabled on environment |
8 | + And the following category | ||
8 | | name | | 9 | | name | |
9 | | social network | | 10 | | social network | |
10 | And the following community | 11 | And the following community |
features/short_filename.feature
@@ -18,4 +18,4 @@ Feature: sitemap | @@ -18,4 +18,4 @@ Feature: sitemap | ||
18 | Scenario: view the CMS | 18 | Scenario: view the CMS |
19 | Given I am logged in as "joaosilva" | 19 | Given I am logged in as "joaosilva" |
20 | When I am on /myprofile/joaosilva/cms | 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,7 +44,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do | | ||
44 | end | 44 | end |
45 | if category && !category.blank? | 45 | if category && !category.blank? |
46 | cat = Category.find_by_slug category | 46 | cat = Category.find_by_slug category |
47 | - organization.categories << cat | 47 | + ProfileCategorization.add_category_to_profile(cat, organization) |
48 | end | 48 | end |
49 | if img_name | 49 | if img_name |
50 | img = Image.create!(:uploaded_data => fixture_file_upload('/files/'+img_name+'.png', 'image/png')) | 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,6 +23,7 @@ end | ||
23 | 23 | ||
24 | Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status| | 24 | Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status| |
25 | e = Environment.default | 25 | e = Environment.default |
26 | + plugin = "#{plugin}Plugin" | ||
26 | if status == 'enabled' | 27 | if status == 'enabled' |
27 | e.enabled_plugins += [plugin] | 28 | e.enabled_plugins += [plugin] |
28 | else | 29 | else |
lib/noosfero.rb
@@ -3,7 +3,7 @@ require 'fast_gettext' | @@ -3,7 +3,7 @@ require 'fast_gettext' | ||
3 | 3 | ||
4 | module Noosfero | 4 | module Noosfero |
5 | PROJECT = 'noosfero' | 5 | PROJECT = 'noosfero' |
6 | - VERSION = '0.44.3' | 6 | + VERSION = '0.44.4' |
7 | 7 | ||
8 | def self.pattern_for_controllers_in_directory(dir) | 8 | def self.pattern_for_controllers_in_directory(dir) |
9 | disjunction = controllers_in_directory(dir).join('|') | 9 | disjunction = controllers_in_directory(dir).join('|') |
lib/noosfero/plugin.rb
@@ -64,6 +64,9 @@ class Noosfero::Plugin | @@ -64,6 +64,9 @@ class Noosfero::Plugin | ||
64 | require init.gsub(/.rb$/, '') if File.file? init | 64 | require init.gsub(/.rb$/, '') if File.file? init |
65 | end | 65 | end |
66 | 66 | ||
67 | + # load extensions | ||
68 | + Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file } | ||
69 | + | ||
67 | # load class | 70 | # load class |
68 | klass(plugin_name) | 71 | klass(plugin_name) |
69 | end | 72 | end |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +raise "Not ready yet" |
plugins/bsc/lib/bsc_plugin.rb
plugins/comment_group/lib/comment_group_plugin.rb
plugins/comment_group/lib/comment_group_plugin/ext/article.rb
@@ -1,21 +0,0 @@ | @@ -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
@@ -0,0 +1,21 @@ | @@ -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/test/unit/comment_group_plugin_test.rb
@@ -10,15 +10,17 @@ class CommentGroupPluginTest < ActiveSupport::TestCase | @@ -10,15 +10,17 @@ class CommentGroupPluginTest < ActiveSupport::TestCase | ||
10 | 10 | ||
11 | attr_reader :environment | 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 | end | 26 | end |
plugins/custom_forms/db/migrate/20130822001407_set_position_to_existent_custom_forms_plugin_fields.rb
0 → 100644
@@ -0,0 +1,9 @@ | @@ -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
plugins/custom_forms/lib/custom_forms_plugin/field.rb
@@ -15,8 +15,12 @@ class CustomFormsPlugin::Field < ActiveRecord::Base | @@ -15,8 +15,12 @@ class CustomFormsPlugin::Field < ActiveRecord::Base | ||
15 | 15 | ||
16 | before_create do |field| | 16 | before_create do |field| |
17 | if field.form.fields.exists? | 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 | end | 19 | end |
20 | end | 20 | end |
21 | + | ||
22 | + def position | ||
23 | + self[:position] || 0 | ||
24 | + end | ||
21 | end | 25 | end |
22 | 26 |
plugins/custom_forms/test/unit/custom_forms_plugin/field_test.rb
@@ -81,5 +81,17 @@ class CustomFormsPlugin::FieldTest < ActiveSupport::TestCase | @@ -81,5 +81,17 @@ class CustomFormsPlugin::FieldTest < ActiveSupport::TestCase | ||
81 | assert_equal 1, field_1.position | 81 | assert_equal 1, field_1.position |
82 | assert_equal 2, field_2.position | 82 | assert_equal 2, field_2.position |
83 | end | 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 | end | 96 | end |
85 | 97 |
plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
@@ -41,7 +41,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -41,7 +41,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
41 | Article.delete_all | 41 | Article.delete_all |
42 | get :index, :block_id => block.id | 42 | get :index, :block_id => block.id |
43 | json_response = ActiveSupport::JSON.decode(@response.body) | 43 | json_response = ActiveSupport::JSON.decode(@response.body) |
44 | - assert_equal [], json_response | 44 | + assert_equivalent [], json_response |
45 | end | 45 | end |
46 | 46 | ||
47 | should 'index action returns an json with node content' do | 47 | should 'index action returns an json with node content' do |
@@ -53,7 +53,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -53,7 +53,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
53 | expected_json = {'data' => article.title} | 53 | expected_json = {'data' => article.title} |
54 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 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 | end | 57 | end |
58 | 58 | ||
59 | should 'index action returns an json with node checked if the node is in the nodes list' do | 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 < ActionController::TestCase | @@ -68,7 +68,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
68 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 68 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} |
69 | expected_json['attr'].merge!({'class' => 'jstree-checked'}) | 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 | end | 72 | end |
73 | 73 | ||
74 | should 'index action returns an json with node undetermined if the node is in the parent nodes list' do | 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 < ActionController::TestCase | @@ -84,7 +84,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
84 | expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) | 84 | expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) |
85 | expected_json['children'] = [] | 85 | expected_json['children'] = [] |
86 | 86 | ||
87 | - assert_equal [expected_json], json_response | 87 | + assert_equivalent [expected_json], json_response |
88 | end | 88 | end |
89 | 89 | ||
90 | should 'index action returns an json with node closed if the node has article with children' do | 90 | should 'index action returns an json with node closed if the node has article with children' do |
@@ -98,7 +98,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -98,7 +98,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
98 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} | 98 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} |
99 | expected_json['state'] = 'closed' | 99 | expected_json['state'] = 'closed' |
100 | 100 | ||
101 | - assert_equal [expected_json], json_response | 101 | + assert_equivalent [expected_json], json_response |
102 | end | 102 | end |
103 | 103 | ||
104 | should 'index action returns an json with all the children nodes if some parent is in the parents list' do | 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 < ActionController::TestCase | @@ -121,7 +121,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
121 | expected_json['children'] = children | 121 | expected_json['children'] = children |
122 | expected_json['state'] = 'closed' | 122 | expected_json['state'] = 'closed' |
123 | 123 | ||
124 | - assert_equal [expected_json], json_response | 124 | + assert_equivalent [expected_json], json_response |
125 | end | 125 | end |
126 | 126 | ||
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 | 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 < ActionController::TestCase | @@ -151,7 +151,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
151 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} | 151 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} |
152 | expected_json.push(value) | 152 | expected_json.push(value) |
153 | 153 | ||
154 | - assert_equal expected_json, json_response | 154 | + assert_equivalent expected_json, json_response |
155 | end | 155 | end |
156 | 156 | ||
157 | should 'index action returns an json without children nodes if the parent is not in the parents list' do | 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 < ActionController::TestCase | @@ -173,7 +173,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
173 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} | 173 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} |
174 | expected_json.push(value) | 174 | expected_json.push(value) |
175 | 175 | ||
176 | - assert_equal expected_json, json_response | 176 | + assert_equivalent expected_json, json_response |
177 | end | 177 | end |
178 | 178 | ||
179 | end | 179 | end |
plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
@@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
41 | Article.delete_all | 41 | Article.delete_all |
42 | get :index, :block_id => block.id, :profile => profile.identifier | 42 | get :index, :block_id => block.id, :profile => profile.identifier |
43 | json_response = ActiveSupport::JSON.decode(@response.body) | 43 | json_response = ActiveSupport::JSON.decode(@response.body) |
44 | - assert_equal [], json_response | 44 | + assert_equivalent [], json_response |
45 | end | 45 | end |
46 | 46 | ||
47 | should 'index action returns an json with node content' do | 47 | should 'index action returns an json with node content' do |
@@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
53 | expected_json = {'data' => article.title} | 53 | expected_json = {'data' => article.title} |
54 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 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 | end | 57 | end |
58 | 58 | ||
59 | should 'index action returns an json with node checked if the node is in the nodes list' do | 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 < ActionController::TestCase | @@ -68,7 +68,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
68 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 68 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} |
69 | expected_json['attr'].merge!({'class' => 'jstree-checked'}) | 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 | end | 72 | end |
73 | 73 | ||
74 | should 'index action returns an json with node undetermined if the node is in the parent nodes list' do | 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 < ActionController::TestCase | @@ -84,7 +84,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
84 | expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) | 84 | expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) |
85 | expected_json['children'] = [] | 85 | expected_json['children'] = [] |
86 | 86 | ||
87 | - assert_equal [expected_json], json_response | 87 | + assert_equivalent [expected_json], json_response |
88 | end | 88 | end |
89 | 89 | ||
90 | should 'index action returns an json with node closed if the node has article with children' do | 90 | should 'index action returns an json with node closed if the node has article with children' do |
@@ -99,7 +99,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -99,7 +99,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
99 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} | 99 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} |
100 | expected_json['state'] = 'closed' | 100 | expected_json['state'] = 'closed' |
101 | 101 | ||
102 | - assert_equal [expected_json], json_response | 102 | + assert_equivalent [expected_json], json_response |
103 | end | 103 | end |
104 | 104 | ||
105 | should 'index action returns an json with all the children nodes if some parent is in the parents list' do | 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 < ActionController::TestCase | @@ -122,7 +122,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
122 | expected_json['children'] = children | 122 | expected_json['children'] = children |
123 | expected_json['state'] = 'closed' | 123 | expected_json['state'] = 'closed' |
124 | 124 | ||
125 | - assert_equal [expected_json], json_response | 125 | + assert_equivalent [expected_json], json_response |
126 | end | 126 | end |
127 | 127 | ||
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 | 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 < ActionController::TestCase | @@ -152,7 +152,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
152 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} | 152 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} |
153 | expected_json.push(value) | 153 | expected_json.push(value) |
154 | 154 | ||
155 | - assert_equal expected_json, json_response | 155 | + assert_equivalent expected_json, json_response |
156 | end | 156 | end |
157 | 157 | ||
158 | should 'index action returns an json without children nodes if the parent is not in the parents list' do | 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 < ActionController::TestCase | @@ -174,7 +174,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
174 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} | 174 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} |
175 | expected_json.push(value) | 175 | expected_json.push(value) |
176 | 176 | ||
177 | - assert_equal expected_json, json_response | 177 | + assert_equivalent expected_json, json_response |
178 | end | 178 | end |
179 | 179 | ||
180 | end | 180 | end |
plugins/foo/lib/foo_plugin.rb
plugins/foo/lib/foo_plugin/ext/profile.rb
plugins/google_analytics/lib/google_analytics_plugin.rb
plugins/ldap/dependencies.rb
@@ -0,0 +1,5 @@ | @@ -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 | require File.dirname(__FILE__) + '/ldap_authentication.rb' | 1 | require File.dirname(__FILE__) + '/ldap_authentication.rb' |
3 | 2 | ||
4 | - | ||
5 | class LdapPlugin < Noosfero::Plugin | 3 | class LdapPlugin < Noosfero::Plugin |
6 | 4 | ||
7 | def self.plugin_name | 5 | def self.plugin_name |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +raise "Not ready yet" |
plugins/pg_search/lib/pg_search_plugin.rb
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin/ext/profile.rb
plugins/send_email/features/send_email_plugin.feature
@@ -7,7 +7,7 @@ Feature: send_email_plugin | @@ -7,7 +7,7 @@ Feature: send_email_plugin | ||
7 | And I am logged in as "joaosilva" | 7 | And I am logged in as "joaosilva" |
8 | 8 | ||
9 | Scenario: expand macro in article content | 9 | Scenario: expand macro in article content |
10 | - Given plugin SendEmailPlugin is enabled on environment | 10 | + Given plugin SendEmail is enabled on environment |
11 | And the following articles | 11 | And the following articles |
12 | | owner | name | body | | 12 | | owner | name | body | |
13 | | joaosilva | sample-article | URL path to {sendemail} action | | 13 | | joaosilva | sample-article | URL path to {sendemail} action | |
@@ -15,7 +15,7 @@ Feature: send_email_plugin | @@ -15,7 +15,7 @@ Feature: send_email_plugin | ||
15 | Then I should see "URL path to /profile/joaosilva/plugin/send_email/deliver action" | 15 | Then I should see "URL path to /profile/joaosilva/plugin/send_email/deliver action" |
16 | 16 | ||
17 | Scenario: expand macro in block content | 17 | Scenario: expand macro in block content |
18 | - Given plugin SendEmailPlugin is enabled on environment | 18 | + Given plugin SendEmail is enabled on environment |
19 | And the following blocks | 19 | And the following blocks |
20 | | owner | type | html | | 20 | | owner | type | html | |
21 | | joaosilva | RawHTMLBlock | URL path to {sendemail} action | | 21 | | joaosilva | RawHTMLBlock | URL path to {sendemail} action | |
plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb
@@ -63,6 +63,7 @@ class ShoppingCartPluginMyprofileController < MyProfileController | @@ -63,6 +63,7 @@ class ShoppingCartPluginMyprofileController < MyProfileController | ||
63 | 63 | ||
64 | def treat_delivery_options(params) | 64 | def treat_delivery_options(params) |
65 | result = {} | 65 | result = {} |
66 | + return result if params.nil? || params[:delivery_options].nil? | ||
66 | params[:options].size.times do |counter| | 67 | params[:options].size.times do |counter| |
67 | if params[:options][counter].present? && params[:prices][counter].present? | 68 | if params[:options][counter].present? && params[:prices][counter].present? |
68 | result[params[:options][counter]] = params[:prices][counter] | 69 | result[params[:options][counter]] = params[:prices][counter] |
plugins/shopping_cart/lib/shopping_cart_plugin.rb
plugins/shopping_cart/lib/shopping_cart_plugin/ext/enterprise.rb
plugins/shopping_cart/lib/shopping_cart_plugin/ext/person.rb
plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
@@ -38,7 +38,7 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase | @@ -38,7 +38,7 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase | ||
38 | value = 13.7 | 38 | value = 13.7 |
39 | environment = Environment.default | 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 | end | 42 | end |
43 | 43 | ||
44 | end | 44 | end |
plugins/shopping_cart/test/unit/shopping_cart_plugin_test.rb
@@ -19,10 +19,9 @@ class ShoppingCartPluginTest < ActiveSupport::TestCase | @@ -19,10 +19,9 @@ class ShoppingCartPluginTest < ActiveSupport::TestCase | ||
19 | end | 19 | end |
20 | 20 | ||
21 | should 'not add button if product unavailable' do | 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 | enterprise.stubs(:shopping_cart).returns(true) | 24 | enterprise.stubs(:shopping_cart).returns(true) |
25 | - product.stubs(:enterprise).returns(enterprise) | ||
26 | 25 | ||
27 | assert_nil shopping_cart.add_to_cart_button(product) | 26 | assert_nil shopping_cart.add_to_cart_button(product) |
28 | end | 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,6 +5,7 @@ Feature: search contents | ||
5 | 5 | ||
6 | Background: | 6 | Background: |
7 | Given the search index is empty | 7 | Given the search index is empty |
8 | + And plugin Solr is enabled on environment | ||
8 | And the following users | 9 | And the following users |
9 | Given the following users | 10 | Given the following users |
10 | | login | name | | 11 | | login | name | |
plugins/solr/features/search_enterprises.feature
@@ -5,6 +5,7 @@ Feature: search enterprises | @@ -5,6 +5,7 @@ Feature: search enterprises | ||
5 | 5 | ||
6 | Background: | 6 | Background: |
7 | Given the search index is empty | 7 | Given the search index is empty |
8 | + And plugin Solr is enabled on environment | ||
8 | And the following enterprises | 9 | And the following enterprises |
9 | | identifier | name | img | | 10 | | identifier | name | img | |
10 | | shop1 | Shoes shop | shoes | | 11 | | shop1 | Shoes shop | shoes | |
@@ -12,6 +13,7 @@ Feature: search enterprises | @@ -12,6 +13,7 @@ Feature: search enterprises | ||
12 | And the following categories as facets | 13 | And the following categories as facets |
13 | | name | | 14 | | name | |
14 | | Temáticas | | 15 | | Temáticas | |
16 | + | ||
15 | Scenario: see default facets when searching | 17 | Scenario: see default facets when searching |
16 | When I go to the search enterprises page | 18 | When I go to the search enterprises page |
17 | And I fill in "search-input" with "shoes" | 19 | And I fill in "search-input" with "shoes" |
@@ -34,10 +36,10 @@ Feature: search enterprises | @@ -34,10 +36,10 @@ Feature: search enterprises | ||
34 | When I go to the search enterprises page | 36 | When I go to the search enterprises page |
35 | And I fill in "search-input" with "Artesanato" | 37 | And I fill in "search-input" with "Artesanato" |
36 | And I press "Search" | 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 | Scenario: find enterprise by region | 44 | Scenario: find enterprise by region |
43 | Given the following cities | 45 | Given the following cities |
plugins/solr/features/search_people.feature
@@ -5,6 +5,7 @@ Feature: search people | @@ -5,6 +5,7 @@ Feature: search people | ||
5 | 5 | ||
6 | Background: | 6 | Background: |
7 | Given the search index is empty | 7 | Given the search index is empty |
8 | + And plugin Solr is enabled on environment | ||
8 | And the following users | 9 | And the following users |
9 | | login | name | | 10 | | login | name | |
10 | | joaosilva | Joao Silva | | 11 | | joaosilva | Joao Silva | |
plugins/solr/features/search_products.feature
@@ -5,6 +5,7 @@ Feature: search products | @@ -5,6 +5,7 @@ Feature: search products | ||
5 | 5 | ||
6 | Background: | 6 | Background: |
7 | Given the search index is empty | 7 | Given the search index is empty |
8 | + And plugin Solr is enabled on environment | ||
8 | And feature "disable_asset_products" is disabled on environment | 9 | And feature "disable_asset_products" is disabled on environment |
9 | And the following enterprises | 10 | And the following enterprises |
10 | | identifier | name | | 11 | | identifier | name | |
plugins/solr/features/step_definitions/solr_steps.rb
@@ -13,6 +13,6 @@ Given /^the following categories as facets$/ do |table| | @@ -13,6 +13,6 @@ Given /^the following categories as facets$/ do |table| | ||
13 | ids << cat.id | 13 | ids << cat.id |
14 | end | 14 | end |
15 | env = Environment.default | 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 | env.save! | 17 | env.save! |
18 | end | 18 | end |
@@ -0,0 +1,14 @@ | @@ -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 < Noosfero::Plugin | @@ -6,8 +6,6 @@ class SolrPlugin < Noosfero::Plugin | ||
6 | 6 | ||
7 | include SolrPlugin::SearchHelper | 7 | include SolrPlugin::SearchHelper |
8 | 8 | ||
9 | - delegate :params, :current_user, :to => :context | ||
10 | - | ||
11 | def self.plugin_name | 9 | def self.plugin_name |
12 | "Solr" | 10 | "Solr" |
13 | end | 11 | end |
@@ -28,11 +26,16 @@ class SolrPlugin < Noosfero::Plugin | @@ -28,11 +26,16 @@ class SolrPlugin < Noosfero::Plugin | ||
28 | return if empty_query?(query, category) && klass != Product | 26 | return if empty_query?(query, category) && klass != Product |
29 | 27 | ||
30 | solr_options = solr_options(class_asset(klass), category) | 28 | solr_options = solr_options(class_asset(klass), category) |
31 | - user = context.send(:logged_in?) ? context.send(:user) : nil | ||
32 | solr_options.merge!(products_options(user)) if klass == Product && empty_query?(query, category) | 29 | solr_options.merge!(products_options(user)) if klass == Product && empty_query?(query, category) |
33 | klass.find_by_contents(query, paginate_options, solr_options.merge(options)) | 30 | klass.find_by_contents(query, paginate_options, solr_options.merge(options)) |
34 | end | 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,7 +54,7 @@ module SolrPlugin::SearchHelper | ||
54 | end | 54 | end |
55 | 55 | ||
56 | def results_only? | 56 | def results_only? |
57 | - context.params[:action] == 'index' | 57 | + params[:action] == 'index' |
58 | end | 58 | end |
59 | 59 | ||
60 | def empty_query?(query, category) | 60 | def empty_query?(query, category) |
@@ -84,18 +84,18 @@ module SolrPlugin::SearchHelper | @@ -84,18 +84,18 @@ module SolrPlugin::SearchHelper | ||
84 | solr_options = {} | 84 | solr_options = {} |
85 | if !multiple_search? | 85 | if !multiple_search? |
86 | if !results_only? and asset_class.respond_to? :facets | 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 | solr_options[:all_facets] = true | 88 | solr_options[:all_facets] = true |
89 | end | 89 | end |
90 | solr_options[:filter_queries] ||= [] | 90 | solr_options[:filter_queries] ||= [] |
91 | solr_options[:filter_queries] += filters(asset) | 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 | solr_options[:filter_queries] << asset_class.facet_category_query.call(category) if category | 93 | solr_options[:filter_queries] << asset_class.facet_category_query.call(category) if category |
94 | 94 | ||
95 | solr_options[:boost_functions] ||= [] | 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 | raise "Unknown order by" if order.nil? | 99 | raise "Unknown order by" if order.nil? |
100 | order[:solr_opts].each do |opt, value| | 100 | order[:solr_opts].each do |opt, value| |
101 | solr_options[opt] = value.is_a?(Proc) ? instance_eval(&value) : value | 101 | solr_options[opt] = value.is_a?(Proc) ? instance_eval(&value) : value |
plugins/solr/public/style.css
1 | .controller-search #search-column-right .search-field .formfield { | 1 | .controller-search #search-column-right .search-field .formfield { |
2 | width: 594px; | 2 | width: 594px; |
3 | - display: inline-block; | 3 | + display: inline; |
4 | } | 4 | } |
5 | 5 | ||
6 | #search-column-right .search-customize-options { | 6 | #search-column-right .search-customize-options { |
7 | - position: absolute; | ||
8 | margin: 0; | 7 | margin: 0; |
9 | padding: 5px 0; | 8 | padding: 5px 0; |
10 | - bottom: 0; | ||
11 | - left: 0; | ||
12 | } | 9 | } |
13 | 10 | ||
14 | #search-column-right .search-results-box .vcard { | 11 | #search-column-right .search-results-box .vcard { |