Commit 012be24d770e8a7480ddfaf444548883d2b6928c

Authored by MoisesMachado
1 parent b4bacb9e

ActionItem6: added the choice of a validation entity for the enterprise

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@315 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/enterprise_controller.rb
... ... @@ -22,6 +22,7 @@ class EnterpriseController < ApplicationController
22 22 def register_form
23 23 @enterprise = Enterprise.new()
24 24 @vitual_communities = VirtualCommunity.find(:all)
  25 + @validation_entities = Organization.find(:all)
25 26 end
26 27  
27 28 def register
... ...
app/models/enterprise.rb
1   -#An enterprise is a kind of profile. According to the system concept, only enterprises can offer products/services
  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
2 2 class Enterprise < Organization
  3 + belongs_to :validation_entity, :class_name => 'organization'
3 4 end
... ...
app/models/organization.rb
... ... @@ -2,4 +2,5 @@ class Organization &lt; Profile
2 2 has_one :organization_info
3 3 has_many :affiliations
4 4 has_many :people, :through => :affiliations
  5 + has_many :validated_enterprises, :class_name => 'enterprise'
5 6 end
... ...
app/views/enterprise/_form.rhtml
... ... @@ -24,3 +24,6 @@
24 24  
25 25 <p><label for="management_information"><%= _('Management Information') %></label><br/>
26 26 <%= text_area 'organization_info', 'management_information', 'cols' => 40, 'rows' => 20 %></p>
  27 +
  28 +<p><label for="validation_entity"><%= _('Validation Entity') %></label><br/>
  29 +<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id] } %></p>
... ...
app/views/enterprise/show.rhtml
... ... @@ -13,3 +13,4 @@
13 13 <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %>
14 14 <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %>
15 15 <%= link_to _('Register new enterprise'), :action => 'register_form' %>
  16 +<%= link_to _('Affiliate'), :action => 'affiliate' %>
... ...
db/migrate/003_create_profiles.rb
... ... @@ -9,11 +9,14 @@ class CreateProfiles &lt; ActiveRecord::Migration
9 9 t.column :flexible_template_theme, :string, :default => "default"
10 10 t.column :flexible_template_icon_theme, :string, :default => "default"
11 11 t.column :active, :boolean, :default => false
12   - t.column :address, :string
13   - t.column :contact_phone, :string
  12 + t.column :address, :string
  13 + t.column :contact_phone, :string
14 14  
15 15 #person fields
16 16 t.column :user_id, :integer
  17 +
  18 + #enterprise fields
  19 + t.column :validation_entity_id, :integer
17 20 end
18 21 end
19 22  
... ...