Commit f1b53f69a1b6cc1a228107f280bc8e03274ea2fd

Authored by Braulio Bhavamitra
1 parent 1ea6b1cb

rails4: fix migration errors with Noosfero::Plugin::ActiveRecord

config/initializers/plugins.rb
1 1 require 'noosfero/plugin'
2 2 require 'noosfero/plugin/hot_spot'
3 3 require 'noosfero/plugin/manager'
4   -require 'noosfero/plugin/active_record'
5 4 require 'noosfero/plugin/mailer_base'
6 5 require 'noosfero/plugin/settings'
7 6 require 'noosfero/plugin/spammable'
... ...
lib/noosfero/plugin.rb
... ... @@ -713,6 +713,5 @@ end
713 713  
714 714 require 'noosfero/plugin/hot_spot'
715 715 require 'noosfero/plugin/manager'
716   -require 'noosfero/plugin/active_record'
717 716 require 'noosfero/plugin/mailer_base'
718 717 require 'noosfero/plugin/settings'
... ...
lib/noosfero/plugin/active_record.rb
... ... @@ -1,7 +0,0 @@
1   -class Noosfero::Plugin::ActiveRecord < ActiveRecord::Base
2   -
3   - def self.inherited(child)
4   - self.table_name = child.name.gsub('::','_').underscore.pluralize
5   - end
6   -
7   -end
plugins/bsc/lib/bsc_plugin/contract.rb
1   -class BscPlugin::Contract < Noosfero::Plugin::ActiveRecord
  1 +class BscPlugin::Contract < ActiveRecord::Base
  2 +
2 3 validates_presence_of :bsc, :client_name
3 4  
4 5 has_many :sales, :class_name => 'BscPlugin::Sale'
... ... @@ -81,4 +82,5 @@ class BscPlugin::Contract &lt; Noosfero::Plugin::ActiveRecord
81 82 def total_price
82 83 sales.inject(0) {|result, sale| sale.price*sale.quantity + result}
83 84 end
  85 +
84 86 end
... ...
plugins/bsc/lib/bsc_plugin/sale.rb
1   -class BscPlugin::Sale < Noosfero::Plugin::ActiveRecord
  1 +class BscPlugin::Sale < ActiveRecord::Base
  2 +
2 3 validates_presence_of :product, :contract
3 4 validates_uniqueness_of :product_id, :scope => :contract_id
4 5 validates_numericality_of :quantity, :only_integer => true, :greater_than_or_equal_to => 0
... ... @@ -16,4 +17,5 @@ class BscPlugin::Sale &lt; Noosfero::Plugin::ActiveRecord
16 17 before_update do |contract|
17 18 contract.updated_at ||= Time.now.utc
18 19 end
  20 +
19 21 end
... ...
plugins/comment_classification/lib/comment_classification_plugin/label.rb
1   -class CommentClassificationPlugin::Label < Noosfero::Plugin::ActiveRecord
  1 +class CommentClassificationPlugin::Label < ActiveRecord::Base
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ... @@ -9,4 +9,5 @@ class CommentClassificationPlugin::Label &lt; Noosfero::Plugin::ActiveRecord
9 9 attr_accessible :name, :enabled, :color
10 10  
11 11 COLORS = ['red', 'green', 'yellow', 'gray', 'blue']
  12 +
12 13 end
... ...
plugins/comment_classification/lib/comment_classification_plugin/status.rb
1   -class CommentClassificationPlugin::Status < Noosfero::Plugin::ActiveRecord
  1 +class CommentClassificationPlugin::Status < ActiveRecord::Base
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ... @@ -7,4 +7,5 @@ class CommentClassificationPlugin::Status &lt; Noosfero::Plugin::ActiveRecord
7 7 validates_presence_of :name
8 8  
9 9 scope :enabled, -> { where enabled: true }
  10 +
10 11 end
... ...
plugins/custom_forms/lib/custom_forms_plugin/form.rb
1   -class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord
  1 +class CustomFormsPlugin::Form < ActiveRecord::Base
  2 +
2 3 belongs_to :profile
3 4  
4 5 has_many :fields, :order => 'position', :class_name => 'CustomFormsPlugin::Field', :dependent => :destroy
... ...
plugins/custom_forms/lib/custom_forms_plugin/submission.rb
1   -class CustomFormsPlugin::Submission < Noosfero::Plugin::ActiveRecord
  1 +class CustomFormsPlugin::Submission < ActiveRecord::Base
  2 +
2 3 belongs_to :form, :class_name => 'CustomFormsPlugin::Form'
3 4 belongs_to :profile
4 5  
... ...
plugins/foo/lib/foo_plugin/bar.rb
1   -class FooPlugin::Bar < Noosfero::Plugin::ActiveRecord
  1 +class FooPlugin::Bar < ActiveRecord::Base
  2 +
2 3 end
... ...
plugins/oauth_client/lib/oauth_client_plugin/provider.rb
1   -class OauthClientPlugin::Provider < Noosfero::Plugin::ActiveRecord
  1 +class OauthClientPlugin::Provider < ActiveRecord::Base
2 2  
3 3 belongs_to :environment
4 4  
... ...
plugins/oauth_client/lib/oauth_client_plugin/user_provider.rb
1   -class OauthClientPlugin::UserProvider < Noosfero::Plugin::ActiveRecord
  1 +class OauthClientPlugin::UserProvider < ActiveRecord::Base
2 2  
3 3 belongs_to :user, :class_name => 'User'
4 4 belongs_to :provider, :class_name => 'OauthClientPlugin::Provider'
... ...
plugins/shopping_cart/lib/shopping_cart_plugin/purchase_order.rb
1   -class ShoppingCartPlugin::PurchaseOrder < Noosfero::Plugin::ActiveRecord
  1 +class ShoppingCartPlugin::PurchaseOrder < ActiveRecord::Base
2 2  
3 3 belongs_to :customer, :class_name => "Profile"
4 4 belongs_to :seller, :class_name => "Profile"
... ...
plugins/sniffer/lib/sniffer_plugin/opportunity.rb
1   -class SnifferPlugin::Opportunity < Noosfero::Plugin::ActiveRecord
  1 +class SnifferPlugin::Opportunity < ActiveRecord::Base
2 2  
3 3 set_table_name :sniffer_plugin_opportunities
4 4  
... ...
plugins/sniffer/lib/sniffer_plugin/profile.rb
1   -class SnifferPlugin::Profile < Noosfero::Plugin::ActiveRecord
  1 +class SnifferPlugin::Profile < ActiveRecord::Base
2 2  
3 3 set_table_name :sniffer_plugin_profiles
4 4  
... ...
plugins/spaminator/lib/spaminator_plugin/report.rb
1   -class SpaminatorPlugin::Report < Noosfero::Plugin::ActiveRecord
  1 +class SpaminatorPlugin::Report < ActiveRecord::Base
  2 +
2 3 serialize :failed, Hash
3 4  
4 5 belongs_to :environment
... ... @@ -29,4 +30,5 @@ class SpaminatorPlugin::Report &lt; Noosfero::Plugin::ActiveRecord
29 30 # TODO Implement some decent visualization
30 31 inspect
31 32 end
  33 +
32 34 end
... ...
plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
1   -class SubOrganizationsPlugin::ApprovePaternityRelation < Noosfero::Plugin::ActiveRecord
  1 +class SubOrganizationsPlugin::ApprovePaternityRelation < ActiveRecord::Base
  2 +
2 3 belongs_to :task
3 4 belongs_to :parent, :polymorphic => true
4 5 belongs_to :child, :polymorphic => true
... ...
plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
1   -class SubOrganizationsPlugin::Relation < Noosfero::Plugin::ActiveRecord
  1 +class SubOrganizationsPlugin::Relation < ActiveRecord::Base
  2 +
2 3 belongs_to :parent, :polymorphic => true
3 4 belongs_to :child, :polymorphic => true
4 5  
... ...
plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb
1   -class ToleranceTimePlugin::Publication < Noosfero::Plugin::ActiveRecord
  1 +class ToleranceTimePlugin::Publication < ActiveRecord::Base
  2 +
2 3 belongs_to :target, :polymorphic => true
3 4 validates_presence_of :target_id, :target_type
4 5 validates_uniqueness_of :target_id, :scope => :target_type
... ...
plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb
1   -class ToleranceTimePlugin::Tolerance < Noosfero::Plugin::ActiveRecord
  1 +class ToleranceTimePlugin::Tolerance < ActiveRecord::Base
  2 +
2 3 belongs_to :profile
3 4 validates_presence_of :profile_id
4 5 validates_uniqueness_of :profile_id
5 6 validates_numericality_of :content_tolerance, :only_integer => true, :allow_nil => true
6 7 validates_numericality_of :comment_tolerance, :only_integer => true, :allow_nil => true
7 8 attr_accessible :profile, :content_tolerance, :comment_tolerance
  9 +
8 10 end
... ...