Commit 3965524711641db613a4baa3885cef8ccf3d49e5

Authored by MoisesMachado
1 parent 9ddf3eb1

ActionItem6: affiliation added

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@184 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/application.rb
@@ -12,9 +12,7 @@ class ApplicationController < ActionController::Base @@ -12,9 +12,7 @@ class ApplicationController < ActionController::Base
12 # Load the owner 12 # Load the owner
13 def load_owner 13 def load_owner
14 # TODO: this should not be hardcoded 14 # TODO: this should not be hardcoded
15 - if Profile.exists?(1)  
16 - @owner = Profile.find(1)  
17 - end 15 + @owner = Profile.find(1) if Profile.exists?(1)
18 end 16 end
19 17
20 protected 18 protected
@@ -30,10 +28,6 @@ class ApplicationController < ActionController::Base @@ -30,10 +28,6 @@ class ApplicationController < ActionController::Base
30 end 28 end
31 end 29 end
32 30
33 - def flexible_template_onwer  
34 - @virtual_community_admin || @profile  
35 - end  
36 -  
37 def self.acts_as_virtual_community_admin_controller 31 def self.acts_as_virtual_community_admin_controller
38 before_filter :load_admin_controller 32 before_filter :load_admin_controller
39 end 33 end
app/controllers/enterprise_controller.rb
1 # Manage enterprises by providing an interface to register, activate and manage them 1 # Manage enterprises by providing an interface to register, activate and manage them
2 class EnterpriseController < ApplicationController 2 class EnterpriseController < ApplicationController
3 3
  4 + def index
  5 + @my_enterprises = current_user.enterprises
  6 + end
  7 +
4 def register 8 def register
5 unless logged_in? 9 unless logged_in?
6 redirect_to :controller => 'account' 10 redirect_to :controller => 'account'
app/models/affiliation.rb 0 → 100644
@@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
  1 +class Affiliation < ActiveRecord::Base
  2 + belongs_to :user
  3 + belongs_to :enterprise
  4 +end
db/migrate/007_create_enterprises.rb
@@ -11,6 +11,7 @@ class CreateEnterprises &lt; ActiveRecord::Migration @@ -11,6 +11,7 @@ class CreateEnterprises &lt; ActiveRecord::Migration
11 t.column :economic_activity, :string 11 t.column :economic_activity, :string
12 t.column :management_information, :string 12 t.column :management_information, :string
13 t.column :active, :boolean, :default => "false" 13 t.column :active, :boolean, :default => "false"
  14 + t.column :manager_id, :integer
14 end 15 end
15 end 16 end
16 17
db/migrate/008_create_affiliations.rb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +class CreateAffiliations < ActiveRecord::Migration
  2 + def self.up
  3 + create_table :affiliations do |t|
  4 + t.column :user_id, :integer
  5 + t.column :enterprise_id, :integer
  6 + end
  7 + end
  8 +
  9 + def self.down
  10 + drop_table :affiliations
  11 + end
  12 +end
test/fixtures/affiliations.yml 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
  2 +one:
  3 + id: 1
  4 +two:
  5 + id: 2
test/unit/affiliation_test.rb 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class AffiliationTest < Test::Unit::TestCase
  4 + fixtures :affiliations
  5 +
  6 + # Replace this with your real tests.
  7 + def test_truth
  8 + assert true
  9 + end
  10 +end