Commit 9a5b65f2f16e47d32a49a978d2de2dd32cc2631c
1 parent
3fcd494a
Exists in
master
and in
28 other branches
ActionItem428: administrator interface to enable/disable enterprises
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2008 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
10 changed files
with
100 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/profile_editor_controller.rb
... | ... | @@ -18,5 +18,25 @@ class ProfileEditorController < MyProfileController |
18 | 18 | end |
19 | 19 | end |
20 | 20 | |
21 | + def enable | |
22 | + @to_enable = profile | |
23 | + if request.post? && params[:confirmation] | |
24 | + unless @to_enable.update_attribute('enabled', true) | |
25 | + flash[:notice] = _('%s was not enabled.') % @to_enable.name | |
26 | + end | |
27 | + redirect_to :action => 'index' | |
28 | + end | |
29 | + end | |
30 | + | |
31 | + def disable | |
32 | + @to_disable = profile | |
33 | + if request.post? && params[:confirmation] | |
34 | + unless @to_disable.update_attribute('enabled', false) | |
35 | + flash[:notice] = _('%s was not disabled.') % @to_disable.name | |
36 | + end | |
37 | + redirect_to :action => 'index' | |
38 | + end | |
39 | + end | |
40 | + | |
21 | 41 | end |
22 | 42 | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +<h1><%= _("Disabling '%s' enterprise") % @to_disable.name %></h1> | |
2 | + | |
3 | +<p> | |
4 | +<%= _('Are you sure you want to disable %s?') % @to_disable.name %> | |
5 | +</p> | |
6 | + | |
7 | +<% form_tag do %> | |
8 | + <%= hidden_field_tag(:confirmation, 1) %> | |
9 | + <%= submit_button(:ok, _("Yes, I want to disable.")) %> | |
10 | + <%= button(:cancel, _("No, I don't want."), :action => 'index') %> | |
11 | +<% end %> | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +<h1><%= _("Enabling '%s' enterprise") % @to_enable.name %></h1> | |
2 | + | |
3 | +<p> | |
4 | +<%= _('Are you sure you want to enable %s?') % @to_enable.name %> | |
5 | +</p> | |
6 | + | |
7 | +<% form_tag do %> | |
8 | + <%= hidden_field_tag(:confirmation, 1) %> | |
9 | + <%= submit_button(:ok, _("Yes, I want to enable.")) %> | |
10 | + <%= button(:cancel, _("No, I don't want."), :action => 'index') %> | |
11 | +<% end %> | ... | ... |
app/views/profile_editor/index.rhtml
... | ... | @@ -28,6 +28,14 @@ |
28 | 28 | |
29 | 29 | <%= file_manager_button(_('Favorite Enterprises'), 'icons-app/favorites.png', :controller => 'favorite_enterprises') if profile.person? %> |
30 | 30 | |
31 | + <% if profile.enterprise? %> | |
32 | + <% if profile.enabled? %> | |
33 | + <%= file_manager_button(_('Disable Enterprise'), 'icons-app/disable.png', :action => 'disable') %> | |
34 | + <% else %> | |
35 | + <%= file_manager_button(_('Enable Enterprise'), 'icons-app/enable.png', :action => 'enable') %> | |
36 | + <% end %> | |
37 | + <% end %> | |
38 | + | |
31 | 39 | <% end %> |
32 | 40 | |
33 | 41 | <% if @profile.person? %> | ... | ... |
public/images/icons-app/README
2.69 KB
3.15 KB
test/functional/profile_editor_controller_test.rb
... | ... | @@ -360,4 +360,52 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
360 | 360 | assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/mailconf' } |
361 | 361 | end |
362 | 362 | |
363 | + should 'link to enable enterprise' do | |
364 | + ent = Enterprise.create!(:name => 'test org', :identifier => 'testent', :enabled => false) | |
365 | + get :index, :profile => 'testent' | |
366 | + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/testent/profile_editor/enable' } | |
367 | + end | |
368 | + | |
369 | + should 'link to disable enterprise' do | |
370 | + ent = Enterprise.create!(:name => 'test org', :identifier => 'testent', :enabled => true) | |
371 | + get :index, :profile => 'testent' | |
372 | + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/testent/profile_editor/disable' } | |
373 | + end | |
374 | + | |
375 | + should 'not link to enable/disable for non enterprises' do | |
376 | + ent = Organization.create!(:name => 'test org', :identifier => 'testorg', :enabled => true) | |
377 | + get :index, :profile => 'testorg' | |
378 | + assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/testorg/profile_editor/disable' } | |
379 | + end | |
380 | + | |
381 | + should 'request enable enterprise confirmation' do | |
382 | + ent = Enterprise.create!(:name => 'test org', :identifier => 'testent', :enabled => false) | |
383 | + get :enable, :profile => 'testent' | |
384 | + assert_tag :tag => 'form', :attributes => { :action => '/myprofile/testent/profile_editor/enable', :method => 'post' } | |
385 | + end | |
386 | + | |
387 | + should 'enable enterprise after confirmation' do | |
388 | + ent = Enterprise.create!(:name => 'test org', :identifier => 'testent', :enabled => false) | |
389 | + post :enable, :profile => 'testent', :confirmation => 1 | |
390 | + assert assigns(:to_enable).enabled? | |
391 | + end | |
392 | + | |
393 | + should 'not enable enterprise without confirmation' do | |
394 | + ent = Enterprise.create!(:name => 'test org', :identifier => 'testent', :enabled => false) | |
395 | + post :enable, :profile => 'testent' | |
396 | + assert !assigns(:to_enable).enabled? | |
397 | + end | |
398 | + | |
399 | + should 'disable enterprise after confirmation' do | |
400 | + ent = Enterprise.create!(:name => 'test org', :identifier => 'testent', :enabled => true) | |
401 | + post :disable, :profile => 'testent', :confirmation => 1 | |
402 | + assert !assigns(:to_disable).enabled? | |
403 | + end | |
404 | + | |
405 | + should 'not disable enterprise without confirmation' do | |
406 | + ent = Enterprise.create!(:name => 'test org', :identifier => 'testent', :enabled => true) | |
407 | + post :disable, :profile => 'testent' | |
408 | + assert assigns(:to_disable).enabled? | |
409 | + end | |
410 | + | |
363 | 411 | end | ... | ... |