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 | 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 < 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/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
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
db/migrate/010_create_organization_infos.rb
test/functional/enterprise_controller_test.rb
... | ... | @@ -129,4 +129,12 @@ class EnterpriseControllerTest < 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 | ... | ... |