Commit 1f71e6736b26f5715246c12294ea931a1c690b48
1 parent
39655247
Exists in
master
and in
29 other branches
ActionItem6: some enterprise level fixes :)
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@185 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
5 additions
and
2 deletions
Show diff stats
app/controllers/enterprise_controller.rb
@@ -2,7 +2,8 @@ | @@ -2,7 +2,8 @@ | ||
2 | class EnterpriseController < ApplicationController | 2 | class EnterpriseController < ApplicationController |
3 | 3 | ||
4 | def index | 4 | def index |
5 | - @my_enterprises = current_user.enterprises | 5 | + @my_enterprises = current_user.enterprises if current_user |
6 | + @enterprises = Enterprise.find(:all) - @my_enterprises | ||
6 | end | 7 | end |
7 | 8 | ||
8 | def register | 9 | def register |
@@ -21,6 +22,7 @@ class EnterpriseController < ApplicationController | @@ -21,6 +22,7 @@ class EnterpriseController < ApplicationController | ||
21 | 22 | ||
22 | def create | 23 | def create |
23 | @enterprise = Enterprise.new(params[:enterprise]) | 24 | @enterprise = Enterprise.new(params[:enterprise]) |
25 | + @enterprise.manager = current_user | ||
24 | if @enterprise.save | 26 | if @enterprise.save |
25 | flash[:notice] = _('Enterprise was succesfully created') | 27 | flash[:notice] = _('Enterprise was succesfully created') |
26 | redirect_to :action => 'register' | 28 | redirect_to :action => 'register' |
app/models/enterprise.rb
@@ -6,6 +6,7 @@ class Enterprise < ActiveRecord::Base | @@ -6,6 +6,7 @@ class Enterprise < ActiveRecord::Base | ||
6 | end | 6 | end |
7 | 7 | ||
8 | has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner | 8 | has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner |
9 | + has_many :affiliations | ||
9 | has_many :users, :through => :affiliation | 10 | has_many :users, :through => :affiliation |
10 | belongs_to :manager, :class_name => 'User' | 11 | belongs_to :manager, :class_name => 'User' |
11 | 12 |
app/models/user.rb
@@ -10,7 +10,7 @@ class User < ActiveRecord::Base | @@ -10,7 +10,7 @@ class User < ActiveRecord::Base | ||
10 | 10 | ||
11 | has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner | 11 | has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner |
12 | has_many :affiliations | 12 | has_many :affiliations |
13 | - has_many :enterprises, :through => :affiliation | 13 | + has_many :enterprises, :through => :affiliations |
14 | # Virtual attribute for the unencrypted password | 14 | # Virtual attribute for the unencrypted password |
15 | attr_accessor :password | 15 | attr_accessor :password |
16 | 16 |