From 5ae25a69593f9e810ccee2b8fea09ba479b98538 Mon Sep 17 00:00:00 2001 From: DanielaFeitosa Date: Fri, 27 Jul 2007 18:32:32 +0000 Subject: [PATCH] ActionItem6: Removing migrate create enterprise and update relations --- app/controllers/enterprise_controller.rb | 9 +++++++-- app/models/affiliation.rb | 2 +- db/migrate/002_create_profiles.rb | 23 ++++++++++++++++++----- db/migrate/007_create_enterprises.rb | 21 --------------------- db/migrate/008_create_affiliations.rb | 2 +- 5 files changed, 27 insertions(+), 30 deletions(-) delete mode 100644 db/migrate/007_create_enterprises.rb diff --git a/app/controllers/enterprise_controller.rb b/app/controllers/enterprise_controller.rb index 12f2460..3168fc1 100644 --- a/app/controllers/enterprise_controller.rb +++ b/app/controllers/enterprise_controller.rb @@ -1,13 +1,14 @@ # Manage enterprises by providing an interface to register, activate and manage them class EnterpriseController < ApplicationController + before_filter :logon + def index - @my_enterprises = current_user.enterprises if current_user + @my_enterprises = current_user.profiles.select{|p| p.kind_of?(Enterprise)} @enterprises = Enterprise.find(:all) - @my_enterprises end def register_form - redirect_to :controller => 'account' unless logged_in? @enterprise = Enterprise.new() @vitual_communities = VirtualCommunity.find(:all) end @@ -24,4 +25,8 @@ class EnterpriseController < ApplicationController render :action => 'register' end end + + def logon + redirect_to :controller => 'account' unless logged_in? + end end diff --git a/app/models/affiliation.rb b/app/models/affiliation.rb index ffa99a3..c0be19a 100644 --- a/app/models/affiliation.rb +++ b/app/models/affiliation.rb @@ -1,4 +1,4 @@ class Affiliation < ActiveRecord::Base belongs_to :user - belongs_to :enterprise + belongs_to :profile end diff --git a/db/migrate/002_create_profiles.rb b/db/migrate/002_create_profiles.rb index dfb108a..b177862 100644 --- a/db/migrate/002_create_profiles.rb +++ b/db/migrate/002_create_profiles.rb @@ -1,14 +1,27 @@ class CreateProfiles < ActiveRecord::Migration def self.up create_table :profiles do |t| - t.column :name, :string - t.column :identifier, :string - t.column :virtual_community_id, :integer - t.column :profile_owner_id, :integer - t.column :profile_owner_type, :string + t.column :name, :string + t.column :identifier, :string + t.column :virtual_community_id, :integer t.column :flexible_template_template, :string, :default => "default" t.column :flexible_template_theme, :string, :default => "default" t.column :flexible_template_icon_theme, :string, :default => "default" + t.column :active, :boolean, :default => "false" + + #person fields + t.column :user_id, :integer + + #enterprise fields + t.column :address, :string + t.column :contact_phone, :string + t.column :contact_person, :string + t.column :acronym, :string + t.column :foundation_year, :integer, :limit => 4 + t.column :legal_form, :string + t.column :economic_activity, :string + t.column :management_information, :string + end end diff --git a/db/migrate/007_create_enterprises.rb b/db/migrate/007_create_enterprises.rb deleted file mode 100644 index 03c9841..0000000 --- a/db/migrate/007_create_enterprises.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateEnterprises < ActiveRecord::Migration - def self.up - create_table :enterprises do |t| - t.column :name, :string - t.column :address, :string - t.column :contact_phone, :string - t.column :contact_person, :string - t.column :acronym, :string - t.column :foundation_year, :integer, :limit => 4 - t.column :legal_form, :string - t.column :economic_activity, :string - t.column :management_information, :string - t.column :active, :boolean, :default => "false" - t.column :manager_id, :integer - end - end - - def self.down - drop_table :enterprises - end -end diff --git a/db/migrate/008_create_affiliations.rb b/db/migrate/008_create_affiliations.rb index 8282383..4bcfd7c 100644 --- a/db/migrate/008_create_affiliations.rb +++ b/db/migrate/008_create_affiliations.rb @@ -2,7 +2,7 @@ class CreateAffiliations < ActiveRecord::Migration def self.up create_table :affiliations do |t| t.column :user_id, :integer - t.column :enterprise_id, :integer + t.column :profile_id, :integer end end -- libgit2 0.21.2