Commit a9a6cb4e14079c7fae88593f3fbb1bb5edfb0e99
1 parent
44e7f2b9
Exists in
master
and in
28 other branches
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
Showing
8 changed files
with
35 additions
and
9 deletions
Show diff stats
app/controllers/enterprise_controller.rb
@@ -30,7 +30,7 @@ class EnterpriseController < ApplicationController | @@ -30,7 +30,7 @@ class EnterpriseController < ApplicationController | ||
30 | @enterprise.organization_info = OrganizationInfo.new(params[:organization]) | 30 | @enterprise.organization_info = OrganizationInfo.new(params[:organization]) |
31 | if @enterprise.save | 31 | if @enterprise.save |
32 | @enterprise.people << @person | 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 | redirect_to :action => 'index' | 34 | redirect_to :action => 'index' |
35 | else | 35 | else |
36 | flash[:notice] = _('Enterprise was not created') | 36 | flash[:notice] = _('Enterprise was not created') |
@@ -72,6 +72,16 @@ class EnterpriseController < ApplicationController | @@ -72,6 +72,16 @@ class EnterpriseController < ApplicationController | ||
72 | @tagged_enterprises = Enterprise.find_tagged_with(params[:query]) | 72 | @tagged_enterprises = Enterprise.find_tagged_with(params[:query]) |
73 | end | 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 | protected | 85 | protected |
76 | 86 | ||
77 | def logon | 87 | def logon |
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 | <p> <%= link_to _('Register new enterprise'), :action => 'register_form' %> </p> | 3 | <p> <%= link_to _('Register new enterprise'), :action => 'register_form' %> </p> |
4 | + | ||
9 | <h2> <%= _('Listing my enterprises') %> </h2> | 5 | <h2> <%= _('Listing my enterprises') %> </h2> |
10 | <ul> | 6 | <ul> |
11 | <%= render :partial => 'enterprise', :collection => @my_active_enterprises %> | 7 | <%= render :partial => 'enterprise', :collection => @my_active_enterprises %> |
app/views/enterprise/register_form.rhtml
@@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
2 | 2 | ||
3 | <h2><%= _('Register enterprise') %></h2> | 3 | <h2><%= _('Register enterprise') %></h2> |
4 | 4 | ||
5 | +<%= _('How to proceed') %> | ||
6 | + | ||
5 | <% form_tag :action => 'register' do %> | 7 | <% form_tag :action => 'register' do %> |
6 | <p><label for="identifier"><%= _('Identifier') %></label><br/> | 8 | <p><label for="identifier"><%= _('Identifier') %></label><br/> |
7 | <%= text_field 'enterprise', 'identifier', 'size' => 20 %></p> | 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 | <h3> <%= @enterprise.name %> </h3> | 5 | <h3> <%= @enterprise.name %> </h3> |
2 | 6 | ||
3 | <p> <%= _('Identifier: ') %> <%= @enterprise.identifier %> </p> | 7 | <p> <%= _('Identifier: ') %> <%= @enterprise.identifier %> </p> |
@@ -13,5 +17,4 @@ | @@ -13,5 +17,4 @@ | ||
13 | 17 | ||
14 | <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %> | 18 | <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %> |
15 | <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %> | 19 | <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %> |
16 | -<%= link_to _('Register new enterprise'), :action => 'register_form' %> | ||
17 | <%= link_to _('Affiliate'), :action => 'affiliate' unless @my_enterprises.include?(@enterprise) %> | 20 | <%= link_to _('Affiliate'), :action => 'affiliate' unless @my_enterprises.include?(@enterprise) %> |
config/environment.rb
@@ -53,7 +53,7 @@ end | @@ -53,7 +53,7 @@ end | ||
53 | # Include your application configuration below | 53 | # Include your application configuration below |
54 | 54 | ||
55 | require 'gettext/rails' | 55 | require 'gettext/rails' |
56 | -require 'extended_tag' | 56 | +#require 'extended_tag' |
57 | Tag.hierarchical = true | 57 | Tag.hierarchical = true |
58 | 58 | ||
59 | Comatose.configure do |config| | 59 | Comatose.configure do |config| |
db/migrate/010_create_organization_infos.rb
@@ -8,6 +8,7 @@ class CreateOrganizationInfos < ActiveRecord::Migration | @@ -8,6 +8,7 @@ class CreateOrganizationInfos < ActiveRecord::Migration | ||
8 | t.column :legal_form, :string | 8 | t.column :legal_form, :string |
9 | t.column :economic_activity, :string | 9 | t.column :economic_activity, :string |
10 | t.column :management_information, :string | 10 | t.column :management_information, :string |
11 | + t.column :validated, :boolean, :default => false | ||
11 | end | 12 | end |
12 | end | 13 | end |
13 | 14 |
test/functional/enterprise_controller_test.rb
@@ -129,4 +129,12 @@ class EnterpriseControllerTest < Test::Unit::TestCase | @@ -129,4 +129,12 @@ class EnterpriseControllerTest < Test::Unit::TestCase | ||
129 | assert assigns(:tagged_enterprises) | 129 | assert assigns(:tagged_enterprises) |
130 | assert_kind_of Array, assigns(:tagged_enterprises) | 130 | assert_kind_of Array, assigns(:tagged_enterprises) |
131 | end | 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 | end | 140 | end |