Commit e3b8008907a0aa13dd0e93b1018c656346f8cdd8
1 parent
9df326c8
Exists in
master
and in
28 other branches
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
Showing
10 changed files
with
129 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -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/views/enterprises/choose_validation_entity_or_net.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 %> | ... | ... |
| ... | ... | @@ -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 | ... | ... |
| ... | ... | @@ -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 | ... | ... |