Commit a9a6cb4e14079c7fae88593f3fbb1bb5edfb0e99

Authored by MoisesMachado
1 parent 44e7f2b9

ActionItem2: added an activate action to the enterprise controller


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@352 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/enterprise_controller.rb
... ... @@ -30,7 +30,7 @@ class EnterpriseController < ApplicationController
30 30 @enterprise.organization_info = OrganizationInfo.new(params[:organization])
31 31 if @enterprise.save
32 32 @enterprise.people << @person
33   - flash[:notice] = _('Enterprise was succesfully created')
  33 + flash[:notice] = _('The enterprise was succesfully created, the validation entity will cotact you as soon as your enterprise is approved')
34 34 redirect_to :action => 'index'
35 35 else
36 36 flash[:notice] = _('Enterprise was not created')
... ... @@ -72,6 +72,16 @@ class EnterpriseController &lt; ApplicationController
72 72 @tagged_enterprises = Enterprise.find_tagged_with(params[:query])
73 73 end
74 74  
  75 + def activate
  76 + @enterprise = Enterprise.find(params[:id])
  77 + if @enterprise.update_attribute('active', true)
  78 + flash[:notice] = 'Enterprise successfuly activacted'
  79 + render :action => 'show'
  80 + else
  81 + redirect_to :action => 'show', :id => @enterprise
  82 + end
  83 + end
  84 +
75 85 protected
76 86  
77 87 def logon
... ...
app/views/enterprise/_search_box.rhtml 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<div class="search_box">
  2 +<% form_tag :action => 'search' do %>
  3 + <%= text_field_tag 'query' %>
  4 + <%= submit_tag _('Search') %>
  5 +<% end %>
  6 +</div>
... ...
app/views/enterprise/list.rhtml
1   -<div class="search_box">
2   -<% form_tag :action => 'search' do %>
3   - <%= text_field_tag 'query' %>
4   - <%= submit_tag _('Search') %>
5   -<% end %>
6   -</div>
  1 +<%= render :partial => 'search_box' %>
7 2  
8 3 <p> <%= link_to _('Register new enterprise'), :action => 'register_form' %> </p>
  4 +
9 5 <h2> <%= _('Listing my enterprises') %> </h2>
10 6 <ul>
11 7 <%= render :partial => 'enterprise', :collection => @my_active_enterprises %>
... ...
app/views/enterprise/register_form.rhtml
... ... @@ -2,6 +2,8 @@
2 2  
3 3 <h2><%= _('Register enterprise') %></h2>
4 4  
  5 +<%= _('How to proceed') %>
  6 +
5 7 <% form_tag :action => 'register' do %>
6 8 <p><label for="identifier"><%= _('Identifier') %></label><br/>
7 9 <%= text_field 'enterprise', 'identifier', 'size' => 20 %></p>
... ...
app/views/enterprise/show.rhtml
  1 +<%= render :partial => 'search_box' %>
  2 +
  3 +<%= link_to _('Register new enterprise'), :action => 'register_form' %>
  4 +
1 5 <h3> <%= @enterprise.name %> </h3>
2 6  
3 7 <p> <%= _('Identifier: ') %> <%= @enterprise.identifier %> </p>
... ... @@ -13,5 +17,4 @@
13 17  
14 18 <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %>
15 19 <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %>
16   -<%= link_to _('Register new enterprise'), :action => 'register_form' %>
17 20 <%= link_to _('Affiliate'), :action => 'affiliate' unless @my_enterprises.include?(@enterprise) %>
... ...
config/environment.rb
... ... @@ -53,7 +53,7 @@ end
53 53 # Include your application configuration below
54 54  
55 55 require 'gettext/rails'
56   -require 'extended_tag'
  56 +#require 'extended_tag'
57 57 Tag.hierarchical = true
58 58  
59 59 Comatose.configure do |config|
... ...
db/migrate/010_create_organization_infos.rb
... ... @@ -8,6 +8,7 @@ class CreateOrganizationInfos &lt; ActiveRecord::Migration
8 8 t.column :legal_form, :string
9 9 t.column :economic_activity, :string
10 10 t.column :management_information, :string
  11 + t.column :validated, :boolean, :default => false
11 12 end
12 13 end
13 14  
... ...
test/functional/enterprise_controller_test.rb
... ... @@ -129,4 +129,12 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase
129 129 assert assigns(:tagged_enterprises)
130 130 assert_kind_of Array, assigns(:tagged_enterprises)
131 131 end
  132 +
  133 + def test_activate
  134 + login_as 'ze'
  135 + post :activate, :id => 5
  136 + assert assigns(:enterprise)
  137 + assert_kind_of Enterprise, assigns(:enterprise)
  138 + assert assigns(:enterprise).active
  139 + end
132 140 end
... ...