Commit fb292e9d0884f013b68f484c542004585bd36b21

Authored by Antonio Terceiro
1 parent 4b901898

Make plugin monkey patches non-ambiguous

plugins/bsc/lib/bsc_plugin.rb
1 -require_dependency 'ext/enterprise'  
2 -require_dependency 'ext/product' 1 +require_dependency 'bsc_plugin/ext/enterprise'
  2 +require_dependency 'bsc_plugin/ext/product'
3 3
4 class BscPlugin < Noosfero::Plugin 4 class BscPlugin < Noosfero::Plugin
5 5
plugins/bsc/lib/bsc_plugin/ext/enterprise.rb 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +require_dependency 'enterprise'
  2 +
  3 +class Enterprise
  4 + belongs_to :bsc, :class_name => 'BscPlugin::Bsc'
  5 + has_and_belongs_to_many :contracts, :class_name => 'BscPlugin::Contract', :join_table => 'bsc_plugin_contracts_enterprises'
  6 +
  7 + FIELDS << 'bsc_id'
  8 + FIELDS << 'enabled'
  9 + FIELDS << 'validated'
  10 +
  11 + named_scope :validated, :conditions => {:validated => true}
  12 + named_scope :not_validated, :conditions => {:validated => false}
  13 +end
plugins/bsc/lib/bsc_plugin/ext/product.rb 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +require_dependency 'product'
  2 +
  3 +class Product
  4 +
  5 + has_many :sales, :class_name => 'BscPlugin::Sale'
  6 + has_many :contracts, :through => :sales, :class_name => 'BscPlugin::Contract'
  7 +
  8 + def bsc
  9 + enterprise.bsc if enterprise
  10 + end
  11 +
  12 + def display_supplier_on_search?
  13 + false
  14 + end
  15 +end
plugins/bsc/lib/ext/enterprise.rb
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -require_dependency 'enterprise'  
2 -  
3 -class Enterprise  
4 - belongs_to :bsc, :class_name => 'BscPlugin::Bsc'  
5 - has_and_belongs_to_many :contracts, :class_name => 'BscPlugin::Contract', :join_table => 'bsc_plugin_contracts_enterprises'  
6 -  
7 - FIELDS << 'bsc_id'  
8 - FIELDS << 'enabled'  
9 - FIELDS << 'validated'  
10 -  
11 - named_scope :validated, :conditions => {:validated => true}  
12 - named_scope :not_validated, :conditions => {:validated => false}  
13 -end  
plugins/bsc/lib/ext/product.rb
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -require_dependency 'product'  
2 -  
3 -class Product  
4 -  
5 - has_many :sales, :class_name => 'BscPlugin::Sale'  
6 - has_many :contracts, :through => :sales, :class_name => 'BscPlugin::Contract'  
7 -  
8 - def bsc  
9 - enterprise.bsc if enterprise  
10 - end  
11 -  
12 - def display_supplier_on_search?  
13 - false  
14 - end  
15 -end  
plugins/shopping_cart/lib/ext/enterprise.rb
@@ -1,5 +0,0 @@ @@ -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/ext/person.rb
@@ -1,5 +0,0 @@ @@ -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/lib/shopping_cart_plugin.rb
1 -require_dependency 'ext/enterprise'  
2 -require_dependency 'ext/person' 1 +require_dependency 'shopping_cart_plugin/ext/enterprise'
  2 +require_dependency 'shopping_cart_plugin/ext/person'
3 3
4 class ShoppingCartPlugin < Noosfero::Plugin 4 class ShoppingCartPlugin < Noosfero::Plugin
5 5
plugins/shopping_cart/lib/shopping_cart_plugin/ext/enterprise.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -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/shopping_cart_plugin/ext/person.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -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