Commit 66771e831aa64bf1a9ac11fe32d207f0a1977b54

Authored by MoisesMachado
1 parent bc8bfd74

ActionItem6: Enterprise controller updated


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@202 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/enterprise_controller.rb
... ... @@ -4,7 +4,7 @@ class EnterpriseController < ApplicationController
4 4 before_filter :logon
5 5  
6 6 def index
7   - @my_enterprises = current_user.profiles.select{|p| p.kind_of?(Enterprise)}
  7 + @my_enterprises = current_user.person.profiles.select{|p| p.kind_of?(Enterprise)}
8 8 @enterprises = Enterprise.find(:all) - @my_enterprises
9 9 end
10 10  
... ... @@ -15,9 +15,8 @@ class EnterpriseController < ApplicationController
15 15  
16 16 def register
17 17 @enterprise = Enterprise.new(params[:enterprise])
18   - @enterprise.manager_id = current_user.id
19 18 if @enterprise.save
20   - @enterprise.users << current_user
  19 + @enterprise.people << current_user.person
21 20 flash[:notice] = _('Enterprise was succesfully created')
22 21 redirect_to :action => 'index'
23 22 else
... ...
app/models/profile.rb
... ... @@ -18,7 +18,7 @@ class Profile &lt; ActiveRecord::Base
18 18 ]
19 19  
20 20 has_many :affiliations
21   - has_many :users, :through => :affiliations
  21 + has_many :people, :through => :affiliations
22 22 has_many :domains, :as => :owner
23 23 belongs_to :virtual_community
24 24 belongs_to :profile_owner, :polymorphic => true
... ...
app/models/user.rb
... ... @@ -9,6 +9,7 @@ class User &lt; ActiveRecord::Base
9 9 end
10 10  
11 11 has_one :person
  12 +
12 13 # Virtual attribute for the unencrypted password
13 14 attr_accessor :password
14 15  
... ...
lib/extended_tag.rb
... ... @@ -13,7 +13,7 @@ class Tag
13 13 end
14 14 end
15 15  
16   -# acts_as_ferret :fields => [:name]
  16 + acts_as_ferret :fields => [:name]
17 17  
18 18  
19 19 # Return all the tags that were suggested but not yet approved
... ...
test/fixtures/profiles.yml
... ... @@ -32,6 +32,7 @@ ze:
32 32 id: 4
33 33 name: "Zé"
34 34 type: 'Person'
  35 + user_id: 3
35 36 identifier: ze
36 37 virtual_community_id: 1
37 38 flexible_template_template: 'default'
... ...