Commit 19586513201c8d553c159906632f491649b88acc
1 parent
aedf055f
Exists in
master
and in
23 other branches
ActionItem14: removing validation stuff from enterprise
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@678 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
2 additions
and
56 deletions
Show diff stats
app/models/enterprise.rb
| 1 | -#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 | |
| 1 | +# An enterprise is a kind of organization. According to the system concept, | |
| 2 | +# only enterprises can offer products and services. | |
| 2 | 3 | class Enterprise < Organization |
| 3 | - belongs_to :validation_entity, :class_name => 'organization', :foreign_key => 'validation_entity_id' | |
| 4 | - has_one :enterprise_info | |
| 5 | - | |
| 6 | - after_create do |enterprise| | |
| 7 | - EnterpriseInfo.create!(:enterprise_id => enterprise.id) | |
| 8 | - end | |
| 9 | - | |
| 10 | - # Test that an enterprise can't be activated unless was previously approved | |
| 11 | -# def validate | |
| 12 | -# if self.active && !self.approved? | |
| 13 | -# errors.add('active', _('Not approved enterprise can\'t be activated')) | |
| 14 | -# end | |
| 15 | -# end | |
| 16 | - | |
| 17 | - # Activate the enterprise so it can be seen by other users | |
| 18 | - def activate | |
| 19 | - self.active = true | |
| 20 | - self.save | |
| 21 | - end | |
| 22 | - | |
| 23 | - # Approve the enterprise so it can be activated by its owner | |
| 24 | - def approve | |
| 25 | - enterprise_info.update_attribute('approval_status', 'approved') | |
| 26 | - end | |
| 27 | - | |
| 28 | - # Reject the approval of the enterprise giving a status message describing its problem | |
| 29 | - def reject(msg = 'rejected', comments = '') | |
| 30 | - enterprise_info.update_attribute('approval_status', msg) | |
| 31 | - enterprise_info.update_attribute('approval_comments', comments) | |
| 32 | - end | |
| 33 | - | |
| 34 | - # Check if the enterprise was approved, that is if the fild approval_status holds the string 'approved' | |
| 35 | - def approved? | |
| 36 | - enterprise_info.approval_status == 'approved' | |
| 37 | - end | |
| 38 | - # Check if the enterprise was rejected, that is if the fild approval_status holds the string 'rejected' | |
| 39 | - def rejected? | |
| 40 | - enterprise_info.approval_status == 'rejected' | |
| 41 | - end | |
| 42 | 4 | end | ... | ... |
app/models/enterprise_info.rb
db/migrate/012_create_enterprise_infos.rb
| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | -class CreateEnterpriseInfos < ActiveRecord::Migration | |
| 2 | - def self.up | |
| 3 | - create_table :enterprise_infos do |t| | |
| 4 | - t.column :approval_status, :string, :default => 'not evaluated' | |
| 5 | - t.column :approval_comments, :text | |
| 6 | - t.column :enterprise_id, :integer | |
| 7 | - end | |
| 8 | - end | |
| 9 | - | |
| 10 | - def self.down | |
| 11 | - drop_table :enterprise_infos | |
| 12 | - end | |
| 13 | -end |