From 19586513201c8d553c159906632f491649b88acc Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 12 Oct 2007 21:25:26 +0000 Subject: [PATCH] ActionItem14: removing validation stuff from enterprise --- app/models/enterprise.rb | 42 ++---------------------------------------- app/models/enterprise_info.rb | 3 --- db/migrate/012_create_enterprise_infos.rb | 13 ------------- 3 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 app/models/enterprise_info.rb delete mode 100644 db/migrate/012_create_enterprise_infos.rb diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 8e7c9a2..ecec2e9 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -1,42 +1,4 @@ -#An enterprise is a kind of organization. According to the system concept, only enterprises can offer products/services and ahave to be validated by an validation entity +# An enterprise is a kind of organization. According to the system concept, +# only enterprises can offer products and services. class Enterprise < Organization - belongs_to :validation_entity, :class_name => 'organization', :foreign_key => 'validation_entity_id' - has_one :enterprise_info - - after_create do |enterprise| - EnterpriseInfo.create!(:enterprise_id => enterprise.id) - end - - # Test that an enterprise can't be activated unless was previously approved -# def validate -# if self.active && !self.approved? -# errors.add('active', _('Not approved enterprise can\'t be activated')) -# end -# end - - # Activate the enterprise so it can be seen by other users - def activate - self.active = true - self.save - end - - # Approve the enterprise so it can be activated by its owner - def approve - enterprise_info.update_attribute('approval_status', 'approved') - end - - # Reject the approval of the enterprise giving a status message describing its problem - def reject(msg = 'rejected', comments = '') - enterprise_info.update_attribute('approval_status', msg) - enterprise_info.update_attribute('approval_comments', comments) - end - - # Check if the enterprise was approved, that is if the fild approval_status holds the string 'approved' - def approved? - enterprise_info.approval_status == 'approved' - end - # Check if the enterprise was rejected, that is if the fild approval_status holds the string 'rejected' - def rejected? - enterprise_info.approval_status == 'rejected' - end end diff --git a/app/models/enterprise_info.rb b/app/models/enterprise_info.rb deleted file mode 100644 index 0dd3a22..0000000 --- a/app/models/enterprise_info.rb +++ /dev/null @@ -1,3 +0,0 @@ -class EnterpriseInfo < ActiveRecord::Base - belongs_to :enterprise -end diff --git a/db/migrate/012_create_enterprise_infos.rb b/db/migrate/012_create_enterprise_infos.rb deleted file mode 100644 index 29478a4..0000000 --- a/db/migrate/012_create_enterprise_infos.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateEnterpriseInfos < ActiveRecord::Migration - def self.up - create_table :enterprise_infos do |t| - t.column :approval_status, :string, :default => 'not evaluated' - t.column :approval_comments, :text - t.column :enterprise_id, :integer - end - end - - def self.down - drop_table :enterprise_infos - end -end -- libgit2 0.21.2