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