diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb new file mode 100644 index 0000000..e9058ec --- /dev/null +++ b/app/controllers/enterprises_controller.rb @@ -0,0 +1,21 @@ +# Manage enterprises by providing an interface to register, activate and manage them +class EnterprisesController < ApplicationController + + def register_form + @vitual_communities = VirtualCommunity.find(:all) + end + + def create + @enterprise = Enterprise.new(params[:enterprise]) + if @enterprise.save + redirect_to :action => 'choose_validation_entity_or_net' + else + render :action => 'register_form' + end + end + + def choose_validation_entity_or_net +# @options = Entity_or_Net.find(:all)) + @options = ['a', 'b', 'c'] + end +end diff --git a/app/helpers/enterprise_helper.rb b/app/helpers/enterprise_helper.rb new file mode 100644 index 0000000..3dcbee5 --- /dev/null +++ b/app/helpers/enterprise_helper.rb @@ -0,0 +1,2 @@ +module EnterpriseHelper +end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb new file mode 100644 index 0000000..a4cf25b --- /dev/null +++ b/app/models/enterprise.rb @@ -0,0 +1,6 @@ +#A enterprise is a kind of profile. According to the system concept, only enterprises can offer priducts/services +class Enterprise < ActiveRecord::Base + + has_one :enterprise_profile, :class_name => Profile + +end diff --git a/app/views/enterprises/choose_validation_entity_or_net.rhtml b/app/views/enterprises/choose_validation_entity_or_net.rhtml new file mode 100644 index 0000000..d8b9846 --- /dev/null +++ b/app/views/enterprises/choose_validation_entity_or_net.rhtml @@ -0,0 +1,5 @@ +

<%= _('Choose validation entity or net') %>

+ + + +<%= link_to _('Register'), :action => '' %> diff --git a/app/views/enterprises/register.rhtml b/app/views/enterprises/register.rhtml new file mode 100644 index 0000000..1892642 --- /dev/null +++ b/app/views/enterprises/register.rhtml @@ -0,0 +1,5 @@ +

<%= _('Information') %>

+ +

Information about how to proceed.

+ +<%= link_to _('Next page'), :action => 'register_form' %> diff --git a/app/views/enterprises/register_form.rhtml b/app/views/enterprises/register_form.rhtml new file mode 100644 index 0000000..43d9b2d --- /dev/null +++ b/app/views/enterprises/register_form.rhtml @@ -0,0 +1,37 @@ +<%= error_messages_for 'enterprise' %> + +

<%= _('Register enterprise') %>

+ +<% form_tag :action => 'create' do %> +


+<%= text_field 'enterprise', 'name', 'size' => 20 %>

+ + + +


+<%= text_field 'enterprise', 'address', 'size' => 50 %>

+ +


+<%= text_field 'enterprise', 'contact_phone', 'size' => 20 %>

+ +


+<%= text_field 'enterprise', 'contact_person', 'size' => 20 %>

+ +


+<%= text_field 'enterprise', 'acronym', 'size' => 20 %>

+ +


+<%= text_field 'enterprise', 'foundation_year', 'size' => 20 %>

+ +


+<%= text_field 'enterprise', 'legal_form', 'size' => 20 %>

+ +


+<%= text_field 'enterprise', 'economic_activity', 'size' => 20 %>

+ +


+<%= text_area 'enterprise', 'management_information', 'cols' => 40, 'rows' => 20 %>

+ +

<%= submit_tag 'Send' %>

+<% end %> diff --git a/db/migrate/007_create_enterprises.rb b/db/migrate/007_create_enterprises.rb new file mode 100644 index 0000000..9771197 --- /dev/null +++ b/db/migrate/007_create_enterprises.rb @@ -0,0 +1,20 @@ +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" + end + end + + def self.down + drop_table :enterprises + end +end diff --git a/test/fixtures/enterprises.yml b/test/fixtures/enterprises.yml new file mode 100644 index 0000000..b49c4eb --- /dev/null +++ b/test/fixtures/enterprises.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 +two: + id: 2 diff --git a/test/functional/enterprise_controller_test.rb b/test/functional/enterprise_controller_test.rb new file mode 100644 index 0000000..44aaece --- /dev/null +++ b/test/functional/enterprise_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'enterprise_controller' + +# Re-raise errors caught by the controller. +class EnterpriseController; def rescue_action(e) raise e end; end + +class EnterpriseControllerTest < Test::Unit::TestCase + def setup + @controller = EnterpriseController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb new file mode 100644 index 0000000..cc4b7db --- /dev/null +++ b/test/unit/enterprise_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class EnterpriseTest < Test::Unit::TestCase + fixtures :profiles + + # Replace this with your real tests. + def test_truth + assert true + end +end -- libgit2 0.21.2