Commit 5ae25a69593f9e810ccee2b8fea09ba479b98538
1 parent
3a88903e
Exists in
master
and in
28 other branches
ActionItem6: Removing migrate create enterprise and update relations
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@189 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
27 additions
and
30 deletions
Show diff stats
app/controllers/enterprise_controller.rb
| 1 | 1 | # Manage enterprises by providing an interface to register, activate and manage them |
| 2 | 2 | class EnterpriseController < ApplicationController |
| 3 | 3 | |
| 4 | + before_filter :logon | |
| 5 | + | |
| 4 | 6 | def index |
| 5 | - @my_enterprises = current_user.enterprises if current_user | |
| 7 | + @my_enterprises = current_user.profiles.select{|p| p.kind_of?(Enterprise)} | |
| 6 | 8 | @enterprises = Enterprise.find(:all) - @my_enterprises |
| 7 | 9 | end |
| 8 | 10 | |
| 9 | 11 | def register_form |
| 10 | - redirect_to :controller => 'account' unless logged_in? | |
| 11 | 12 | @enterprise = Enterprise.new() |
| 12 | 13 | @vitual_communities = VirtualCommunity.find(:all) |
| 13 | 14 | end |
| ... | ... | @@ -24,4 +25,8 @@ class EnterpriseController < ApplicationController |
| 24 | 25 | render :action => 'register' |
| 25 | 26 | end |
| 26 | 27 | end |
| 28 | + | |
| 29 | + def logon | |
| 30 | + redirect_to :controller => 'account' unless logged_in? | |
| 31 | + end | |
| 27 | 32 | end | ... | ... |
app/models/affiliation.rb
db/migrate/002_create_profiles.rb
| 1 | 1 | class CreateProfiles < ActiveRecord::Migration |
| 2 | 2 | def self.up |
| 3 | 3 | create_table :profiles do |t| |
| 4 | - t.column :name, :string | |
| 5 | - t.column :identifier, :string | |
| 6 | - t.column :virtual_community_id, :integer | |
| 7 | - t.column :profile_owner_id, :integer | |
| 8 | - t.column :profile_owner_type, :string | |
| 4 | + t.column :name, :string | |
| 5 | + t.column :identifier, :string | |
| 6 | + t.column :virtual_community_id, :integer | |
| 9 | 7 | t.column :flexible_template_template, :string, :default => "default" |
| 10 | 8 | t.column :flexible_template_theme, :string, :default => "default" |
| 11 | 9 | t.column :flexible_template_icon_theme, :string, :default => "default" |
| 10 | + t.column :active, :boolean, :default => "false" | |
| 11 | + | |
| 12 | + #person fields | |
| 13 | + t.column :user_id, :integer | |
| 14 | + | |
| 15 | + #enterprise fields | |
| 16 | + t.column :address, :string | |
| 17 | + t.column :contact_phone, :string | |
| 18 | + t.column :contact_person, :string | |
| 19 | + t.column :acronym, :string | |
| 20 | + t.column :foundation_year, :integer, :limit => 4 | |
| 21 | + t.column :legal_form, :string | |
| 22 | + t.column :economic_activity, :string | |
| 23 | + t.column :management_information, :string | |
| 24 | + | |
| 12 | 25 | end |
| 13 | 26 | end |
| 14 | 27 | ... | ... |
db/migrate/007_create_enterprises.rb
| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | -class CreateEnterprises < ActiveRecord::Migration | |
| 2 | - def self.up | |
| 3 | - create_table :enterprises do |t| | |
| 4 | - t.column :name, :string | |
| 5 | - t.column :address, :string | |
| 6 | - t.column :contact_phone, :string | |
| 7 | - t.column :contact_person, :string | |
| 8 | - t.column :acronym, :string | |
| 9 | - t.column :foundation_year, :integer, :limit => 4 | |
| 10 | - t.column :legal_form, :string | |
| 11 | - t.column :economic_activity, :string | |
| 12 | - t.column :management_information, :string | |
| 13 | - t.column :active, :boolean, :default => "false" | |
| 14 | - t.column :manager_id, :integer | |
| 15 | - end | |
| 16 | - end | |
| 17 | - | |
| 18 | - def self.down | |
| 19 | - drop_table :enterprises | |
| 20 | - end | |
| 21 | -end |
db/migrate/008_create_affiliations.rb