Commit 9a1bc7ba08f8575516a813fa274f4d49b7027e7c
Exists in
master
and in
29 other branches
Merge branch 'AI3021-ban_user' of https://gitlab.com/unb-gama/noosfero into AI3021-ban_user
Showing
4 changed files
with
72 additions
and
5 deletions
Show diff stats
app/controllers/admin/users_controller.rb
... | ... | @@ -45,6 +45,20 @@ class UsersController < AdminController |
45 | 45 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
46 | 46 | end |
47 | 47 | |
48 | + | |
49 | + def destroy_user | |
50 | + if request.post? | |
51 | + person = environment.people.find(params[:id]) | |
52 | + if person.destroy | |
53 | + session[:notice] = _('The profile was deleted.') | |
54 | + else | |
55 | + session[:notice] = _('Could not delete profile') | |
56 | + end | |
57 | + end | |
58 | + redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | |
59 | + end | |
60 | + | |
61 | + | |
48 | 62 | def download |
49 | 63 | respond_to do |format| |
50 | 64 | format.html | ... | ... |
app/views/users/_users_list.rhtml
... | ... | @@ -19,16 +19,17 @@ |
19 | 19 | <td class='actions'> |
20 | 20 | <div class="members-buttons-cell"> |
21 | 21 | <% if p.is_admin? %> |
22 | - <%= button_without_text :'reset-admin-role', _('Reset admin role'), :action => 'reset_admin_role', :id => p, :q => @q, :filter => @filter %> | |
22 | + <%= button_without_text :'reset-admin-role', _('Reset admin role'), {:action => 'reset_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to reset this user as administrator?") %> | |
23 | 23 | <% else %> |
24 | - <%= button_without_text :'set-admin-role', _('Set admin role'), :action => 'set_admin_role', :id => p, :q => @q, :filter => @filter %> | |
24 | + <%= button_without_text :'set-admin-role', _('Set admin role'), {:action => 'set_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to set this user as administrator?") %> | |
25 | 25 | <% end %> |
26 | 26 | <% if !p.user.activated? %> |
27 | - <%= button_without_text :'activate-user', _('Activate user'), :action => 'activate', :id => p, :q => @q, :filter => @filter %> | |
27 | + <%= button_without_text :'activate-user', _('Activate user'), {:action => 'activate', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to activate this user?") %> | |
28 | 28 | <% else %> |
29 | - <%= button_without_text :'deactivate-user', _('Deactivate user'), :action => 'deactivate', :id => p, :q => @q, :filter => @filter %> | |
29 | + <%= button_without_text :'deactivate-user', _('Deactivate user'), {:action => 'deactivate', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to deactivate this user?") %> | |
30 | 30 | <% end %> |
31 | - </div> | |
31 | + <%= button_without_text :'delete', _('Remove'), {:action => :destroy_user, :id => p, :q => @q}, :method => :post, :filter => @filter, :confirm => _("Do you want to remove this user?") %> | |
32 | + </div> | |
32 | 33 | </td> |
33 | 34 | </tr> |
34 | 35 | <% end %> | ... | ... |
... | ... | @@ -0,0 +1,47 @@ |
1 | +Feature: manage users | |
2 | + As an environment administrator | |
3 | + I want to manage users | |
4 | + In order to remove, activate, deactivate users, and set admin roles. | |
5 | + | |
6 | +Background: | |
7 | + Given the following users | |
8 | + | login | name | | |
9 | + | joaosilva | Joao Silva | | |
10 | + | paulosantos | Paulo Santos | | |
11 | + Given I am logged in as admin | |
12 | + Given I go to /admin/users | |
13 | + | |
14 | + @selenium | |
15 | + Scenario: deactive user | |
16 | + When I follow "Deactivate user" within "tr[title='Joao Silva']" | |
17 | + And I confirm the "Do you want to deactivate this user?" dialog | |
18 | + Then I should see "Activate user" within "tr[title='Joao Silva']" | |
19 | + | |
20 | + @selenium | |
21 | + Scenario: activate user | |
22 | + Given I follow "Deactivate user" within "tr[title='Paulo Santos']" | |
23 | + Given I confirm the "Do you want to deactivate this user?" dialog | |
24 | + When I follow "Activate user" within "tr[title='Paulo Santos']" | |
25 | + And I confirm the "Do you want to activate this user?" dialog | |
26 | + Then I should see "Deactivate user" within "tr[title='Paulo Santos']" | |
27 | + | |
28 | + @selenium | |
29 | + Scenario: ban user | |
30 | + When I follow "Remove" within "tr[title='Joao Silva']" | |
31 | + And I confirm the "Do you want to remove this user?" dialog | |
32 | + And I go to /admin/users | |
33 | + Then I should not see "Joao Silva" | |
34 | + | |
35 | + @selenium | |
36 | + Scenario: admin user | |
37 | + When I follow "Set admin role" within "tr[title='Joao Silva']" | |
38 | + And I confirm the "Do you want to set this user as administrator?" dialog | |
39 | + Then I should see "Reset admin role" within "tr[title='Joao Silva']" | |
40 | + | |
41 | + @selenium | |
42 | + Scenario: unadmin user | |
43 | + Given I follow "Set admin role" within "tr[title='Paulo Santos']" | |
44 | + And I confirm the "Do you want to set this user as administrator?" dialog | |
45 | + When I follow "Reset admin role" within "tr[title='Paulo Santos']" | |
46 | + And I confirm the "Do you want to reset this user as administrator?" dialog | |
47 | + Then I should see "Set admin role" within "tr[title='Paulo Santos']" | |
0 | 48 | \ No newline at end of file | ... | ... |
public/stylesheets/application.css
... | ... | @@ -4196,6 +4196,11 @@ h1#agenda-title { |
4196 | 4196 | display: block; |
4197 | 4197 | float: left; |
4198 | 4198 | } |
4199 | + | |
4200 | +.actions .members-buttons-cell { | |
4201 | + width : 100px | |
4202 | +} | |
4203 | + | |
4199 | 4204 | .controller-profile_members .msie6 .button-bar a { |
4200 | 4205 | position: relative; |
4201 | 4206 | } | ... | ... |