Commit e3b8008907a0aa13dd0e93b1018c656346f8cdd8

Authored by DanielaFeitosa
1 parent 9df326c8

ActionItem6: adding enterprise's model, controller, migrate and views


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@166 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/enterprises_controller.rb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +# Manage enterprises by providing an interface to register, activate and manage them
  2 +class EnterprisesController < ApplicationController
  3 +
  4 + def register_form
  5 + @vitual_communities = VirtualCommunity.find(:all)
  6 + end
  7 +
  8 + def create
  9 + @enterprise = Enterprise.new(params[:enterprise])
  10 + if @enterprise.save
  11 + redirect_to :action => 'choose_validation_entity_or_net'
  12 + else
  13 + render :action => 'register_form'
  14 + end
  15 + end
  16 +
  17 + def choose_validation_entity_or_net
  18 +# @options = Entity_or_Net.find(:all))
  19 + @options = ['a', 'b', 'c']
  20 + end
  21 +end
... ...
app/helpers/enterprise_helper.rb 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +module EnterpriseHelper
  2 +end
... ...
app/models/enterprise.rb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +#A enterprise is a kind of profile. According to the system concept, only enterprises can offer priducts/services
  2 +class Enterprise < ActiveRecord::Base
  3 +
  4 + has_one :enterprise_profile, :class_name => Profile
  5 +
  6 +end
... ...
app/views/enterprises/choose_validation_entity_or_net.rhtml 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +<h2><%= _('Choose validation entity or net') %></h2>
  2 +
  3 +<!-- list of entities or nets -->
  4 +
  5 +<%= link_to _('Register'), :action => '' %>
... ...
app/views/enterprises/register.rhtml 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +<h2><%= _('Information') %></h2>
  2 +
  3 +<p>Information about how to proceed.</p>
  4 +
  5 +<%= link_to _('Next page'), :action => 'register_form' %>
... ...
app/views/enterprises/register_form.rhtml 0 → 100644
... ... @@ -0,0 +1,37 @@
  1 +<%= error_messages_for 'enterprise' %>
  2 +
  3 +<h2><%= _('Register enterprise') %></h2>
  4 +
  5 +<% form_tag :action => 'create' do %>
  6 +<p><label for="name"><%= _('Name') %></label><br/>
  7 +<%= text_field 'enterprise', 'name', 'size' => 20 %></p>
  8 +
  9 +<!-- <p><label for='virtual_community_id'>< %= _('Virtual Community') %></label><br/>
  10 +< %= select 'enterprise', 'virtual_community_id', @vitual_communities.collect { |v| [v.name, v.id] } %> -->
  11 +
  12 +<p><label for="address"><%= _('Address') %></label><br/>
  13 +<%= text_field 'enterprise', 'address', 'size' => 50 %></p>
  14 +
  15 +<p><label for="contact_phone"><%= _('Contact Phone') %></label><br/>
  16 +<%= text_field 'enterprise', 'contact_phone', 'size' => 20 %></p>
  17 +
  18 +<p><label for="contact_person"><%= _('Contact Person') %></label><br/>
  19 +<%= text_field 'enterprise', 'contact_person', 'size' => 20 %></p>
  20 +
  21 +<p><label for="acronym"><%= _('Acronym') %></label><br/>
  22 +<%= text_field 'enterprise', 'acronym', 'size' => 20 %></p>
  23 +
  24 +<p><label for="foundation_year"><%= _('Foundation Year') %></label><br/>
  25 +<%= text_field 'enterprise', 'foundation_year', 'size' => 20 %></p>
  26 +
  27 +<p><label for="legal_form"><%= _('Legal Form') %></label><br/>
  28 +<%= text_field 'enterprise', 'legal_form', 'size' => 20 %></p>
  29 +
  30 +<p><label for="economic_activity"><%= _('Economic Activity') %></label><br/>
  31 +<%= text_field 'enterprise', 'economic_activity', 'size' => 20 %></p>
  32 +
  33 +<p><label for="management_information"><%= _('Management Information') %></label><br/>
  34 +<%= text_area 'enterprise', 'management_information', 'cols' => 40, 'rows' => 20 %></p>
  35 +
  36 +<p><%= submit_tag 'Send' %></p>
  37 +<% end %>
... ...
db/migrate/007_create_enterprises.rb 0 → 100644
... ... @@ -0,0 +1,20 @@
  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 + end
  15 + end
  16 +
  17 + def self.down
  18 + drop_table :enterprises
  19 + end
  20 +end
... ...
test/fixtures/enterprises.yml 0 → 100644
... ... @@ -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/functional/enterprise_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +require 'enterprise_controller'
  3 +
  4 +# Re-raise errors caught by the controller.
  5 +class EnterpriseController; def rescue_action(e) raise e end; end
  6 +
  7 +class EnterpriseControllerTest < Test::Unit::TestCase
  8 + def setup
  9 + @controller = EnterpriseController.new
  10 + @request = ActionController::TestRequest.new
  11 + @response = ActionController::TestResponse.new
  12 + end
  13 +
  14 + # Replace this with your real tests.
  15 + def test_truth
  16 + assert true
  17 + end
  18 +end
... ...
test/unit/enterprise_test.rb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class EnterpriseTest < Test::Unit::TestCase
  4 + fixtures :profiles
  5 +
  6 + # Replace this with your real tests.
  7 + def test_truth
  8 + assert true
  9 + end
  10 +end
... ...