Commit da22d0c821ec25ddda9946a4c8662ccf3328872c
Exists in
master
and in
29 other branches
Merge branch 'master' into AI2928-categories
Showing
11 changed files
with
341 additions
and
36 deletions
Show diff stats
app/controllers/admin/users_controller.rb
@@ -45,6 +45,20 @@ class UsersController < AdminController | @@ -45,6 +45,20 @@ class UsersController < AdminController | ||
45 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | 45 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
46 | end | 46 | end |
47 | 47 | ||
48 | + | ||
49 | + def destroy_user | ||
50 | + if request.post? | ||
51 | + person = environment.people.find_by_id(params[:id]) | ||
52 | + if person && person.destroy | ||
53 | + session[:notice] = _('The profile was deleted.') | ||
54 | + else | ||
55 | + session[:notice] = _('Could not remove profile') | ||
56 | + end | ||
57 | + end | ||
58 | + redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | ||
59 | + end | ||
60 | + | ||
61 | + | ||
48 | def download | 62 | def download |
49 | respond_to do |format| | 63 | respond_to do |format| |
50 | format.html | 64 | format.html |
app/views/features/_manage_community_fields.rhtml
1 | -<h2><%= __('Manage community fields') %></h2> | ||
2 | - | ||
3 | <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_community_fields'}) do |f| %> | 1 | <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_community_fields'}) do |f| %> |
4 | 2 | ||
5 | <table id='community_fields_conf'> | 3 | <table id='community_fields_conf'> |
@@ -9,21 +7,37 @@ | @@ -9,21 +7,37 @@ | ||
9 | <th><%= _('Required') %></th> | 7 | <th><%= _('Required') %></th> |
10 | <th><%= _('Display on creation?') %></th> | 8 | <th><%= _('Display on creation?') %></th> |
11 | </tr> | 9 | </tr> |
10 | + | ||
11 | + <tr class='manage-fields-batch-actions'> | ||
12 | + <td> | ||
13 | + <%= _("Check/Uncheck All")%> | ||
14 | + </td> | ||
15 | + <td> | ||
16 | + <input type="checkbox" id="community_active" /> | ||
17 | + </td> | ||
18 | + <td> | ||
19 | + <input type="checkbox" id="community_required" /> | ||
20 | + </td> | ||
21 | + <td> | ||
22 | + <input type="checkbox" id="community_signup" /> | ||
23 | + </td> | ||
24 | + </tr> | ||
25 | + | ||
12 | <% @community_fields.each do |field| %> | 26 | <% @community_fields.each do |field| %> |
13 | <tr> | 27 | <tr> |
14 | <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> | 28 | <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
15 | 29 | ||
16 | <td> | 30 | <td> |
17 | <%= hidden_field_tag "community_fields[#{field}][active]", false %> | 31 | <%= hidden_field_tag "community_fields[#{field}][active]", false %> |
18 | - <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "$('community_fields[#{field}][required]').disabled=$('community_fields[#{field}][signup]').disabled=!this.checked;" %> | 32 | + <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "active_action(this, 'community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> |
19 | </td> | 33 | </td> |
20 | <td> | 34 | <td> |
21 | <%= hidden_field_tag "community_fields[#{field}][required]", false %> | 35 | <%= hidden_field_tag "community_fields[#{field}][required]", false %> |
22 | - <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "if(this.checked) $('community_fields[#{field}][signup]').checked = true;" %> | 36 | + <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "required_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> |
23 | </td> | 37 | </td> |
24 | <td> | 38 | <td> |
25 | <%= hidden_field_tag "community_fields[#{field}][signup]", false %> | 39 | <%= hidden_field_tag "community_fields[#{field}][signup]", false %> |
26 | - <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "if(!this.checked) $('community_fields[#{field}][required]').checked = false;" %> | 40 | + <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "signup_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> |
27 | </td> | 41 | </td> |
28 | 42 | ||
29 | </tr> | 43 | </tr> |
@@ -31,18 +45,18 @@ | @@ -31,18 +45,18 @@ | ||
31 | </table> | 45 | </table> |
32 | 46 | ||
33 | <script type='text/javascript'> | 47 | <script type='text/javascript'> |
34 | - var trs = $$('#community_fields_conf tr'); | 48 | + var trs = jQuery('#community_fields_conf tr'); |
35 | var tr, td2; | 49 | var tr, td2; |
36 | - for ( var i=0; tr=trs[i]; i++ ) { | 50 | + for ( var i=2; tr=trs[i]; i++ ) { |
37 | if ( td2 = tr.getElementsByTagName('td')[1] ) { | 51 | if ( td2 = tr.getElementsByTagName('td')[1] ) { |
38 | - td2.getElementsByTagName('input')[0].onclick(); | 52 | + td2.getElementsByTagName('input')[1].onclick(); |
39 | } | 53 | } |
40 | } | 54 | } |
41 | </script> | 55 | </script> |
42 | 56 | ||
43 | <div> | 57 | <div> |
44 | <% button_bar do %> | 58 | <% button_bar do %> |
45 | - <%= submit_button('save', _('Save changes')) %> | 59 | + <%= submit_button('save', _('Save changes'), :id=>"save_community_fields") %> |
46 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> | 60 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> |
47 | <% end %> | 61 | <% end %> |
48 | </div> | 62 | </div> |
app/views/features/_manage_enterprise_fields.rhtml
1 | -<h2><%= __('Manage enterprise fields') %></h2> | ||
2 | - | ||
3 | <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_enterprise_fields'}) do |f| %> | 1 | <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_enterprise_fields'}) do |f| %> |
4 | 2 | ||
5 | <table id='enterprise_fields_conf'> | 3 | <table id='enterprise_fields_conf'> |
@@ -9,21 +7,37 @@ | @@ -9,21 +7,37 @@ | ||
9 | <th><%= _('Required') %></th> | 7 | <th><%= _('Required') %></th> |
10 | <th><%= _('Display on registration?') %></th> | 8 | <th><%= _('Display on registration?') %></th> |
11 | </tr> | 9 | </tr> |
10 | + | ||
11 | + <tr class='manage-fields-batch-actions'> | ||
12 | + <td> | ||
13 | + <%= _("Check/Uncheck All")%> | ||
14 | + </td> | ||
15 | + <td> | ||
16 | + <input type="checkbox" id="enterprise_active" /> | ||
17 | + </td> | ||
18 | + <td> | ||
19 | + <input type="checkbox" id="enterprise_required" /> | ||
20 | + </td> | ||
21 | + <td> | ||
22 | + <input type="checkbox" id="enterprise_signup" /> | ||
23 | + </td> | ||
24 | + </tr> | ||
25 | + | ||
12 | <% @enterprise_fields.each do |field| %> | 26 | <% @enterprise_fields.each do |field| %> |
13 | <tr> | 27 | <tr> |
14 | 28 | ||
15 | <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> | 29 | <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
16 | <td> | 30 | <td> |
17 | <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> | 31 | <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> |
18 | - <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "$('enterprise_fields[#{field}][required]').disabled=$('enterprise_fields[#{field}][signup]').disabled=!this.checked;" %> | 32 | + <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "active_action(this, 'enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> |
19 | </td> | 33 | </td> |
20 | <td> | 34 | <td> |
21 | <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> | 35 | <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> |
22 | - <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required'), :onclick => "if(this.checked) $('enterprise_fields[#{field}][signup]').checked = true;" %> | 36 | + <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required'), :onclick => "required_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> |
23 | </td> | 37 | </td> |
24 | <td> | 38 | <td> |
25 | <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> | 39 | <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> |
26 | - <%= check_box_tag "enterprise_fields[#{field}][signup]", true, environment.custom_enterprise_field(field, 'signup'), :onclick => "if(!this.checked) $('enterprise_fields[#{field}][required]').checked = false;" %> | 40 | + <%= check_box_tag "enterprise_fields[#{field}][signup]", true, environment.custom_enterprise_field(field, 'signup'), :onclick => "signup_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> |
27 | </td> | 41 | </td> |
28 | 42 | ||
29 | </tr> | 43 | </tr> |
@@ -31,18 +45,18 @@ | @@ -31,18 +45,18 @@ | ||
31 | </table> | 45 | </table> |
32 | 46 | ||
33 | <script type='text/javascript'> | 47 | <script type='text/javascript'> |
34 | - var trs = $$('#enterprise_fields_conf tr'); | 48 | + var trs = jQuery('#enterprise_fields_conf tr'); |
35 | var tr, td2; | 49 | var tr, td2; |
36 | - for ( var i=0; tr=trs[i]; i++ ) { | 50 | + for ( var i=2; tr=trs[i]; i++ ) { |
37 | if ( td2 = tr.getElementsByTagName('td')[1] ) { | 51 | if ( td2 = tr.getElementsByTagName('td')[1] ) { |
38 | - td2.getElementsByTagName('input')[0].onclick(); | 52 | + td2.getElementsByTagName('input')[1].onclick(); |
39 | } | 53 | } |
40 | } | 54 | } |
41 | </script> | 55 | </script> |
42 | 56 | ||
43 | <div> | 57 | <div> |
44 | <% button_bar do %> | 58 | <% button_bar do %> |
45 | - <%= submit_button('save', _('Save changes')) %> | 59 | + <%= submit_button('save', _('Save changes'), :id=>"save_enterprise_fields") %> |
46 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> | 60 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> |
47 | <% end %> | 61 | <% end %> |
48 | </div> | 62 | </div> |
app/views/features/_manage_person_fields.rhtml
1 | -<h2><%= _('Manage person fields') %></h2> | ||
2 | - | ||
3 | <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_person_fields'}) do |f| %> | 1 | <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_person_fields'}) do |f| %> |
4 | 2 | ||
5 | <table id='person_fields_conf'> | 3 | <table id='person_fields_conf'> |
@@ -9,31 +7,48 @@ | @@ -9,31 +7,48 @@ | ||
9 | <th><%= _('Required') %></th> | 7 | <th><%= _('Required') %></th> |
10 | <th><%= _('Display on signup?') %></th> | 8 | <th><%= _('Display on signup?') %></th> |
11 | </tr> | 9 | </tr> |
10 | + | ||
11 | + <tr class='manage-fields-batch-actions'> | ||
12 | + <td> | ||
13 | + <%= _("Check/Uncheck All")%> | ||
14 | + </td> | ||
15 | + <td> | ||
16 | + <input type="checkbox" id="person_active" /> | ||
17 | + </td> | ||
18 | + <td> | ||
19 | + <input type="checkbox" id="person_required" /> | ||
20 | + </td> | ||
21 | + <td> | ||
22 | + <input type="checkbox" id="person_signup" /> | ||
23 | + </td> | ||
24 | + </tr> | ||
25 | + | ||
12 | <% @person_fields.each do |field| %> | 26 | <% @person_fields.each do |field| %> |
13 | <tr> | 27 | <tr> |
14 | <td><label for="person_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> | 28 | <td><label for="person_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
15 | <td> | 29 | <td> |
16 | <%= hidden_field_tag "person_fields[#{field}][active]", false %> | 30 | <%= hidden_field_tag "person_fields[#{field}][active]", false %> |
17 | - <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "$('person_fields[#{field}][required]').disabled=$('person_fields[#{field}][signup]').disabled=!this.checked;" %> | 31 | + <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "active_action(this, 'person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> |
18 | </td> | 32 | </td> |
19 | <td> | 33 | <td> |
20 | <%= hidden_field_tag "person_fields[#{field}][required]", false %> | 34 | <%= hidden_field_tag "person_fields[#{field}][required]", false %> |
21 | - <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required'), :onclick => "if(this.checked) $('person_fields[#{field}][signup]').checked = true;" %> | 35 | + <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required'), :onclick => "required_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> |
22 | </td> | 36 | </td> |
23 | <td> | 37 | <td> |
24 | <%= hidden_field_tag "person_fields[#{field}][signup]", false %> | 38 | <%= hidden_field_tag "person_fields[#{field}][signup]", false %> |
25 | - <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "if(!this.checked) $('person_fields[#{field}][required]').checked = false;" %> | 39 | + <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "signup_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> |
26 | </td> | 40 | </td> |
27 | </tr> | 41 | </tr> |
28 | <% end %> | 42 | <% end %> |
29 | </table> | 43 | </table> |
30 | 44 | ||
31 | <script type='text/javascript'>// <!-- | 45 | <script type='text/javascript'>// <!-- |
32 | - var trs = $$('#person_fields_conf tr'); | 46 | + var trs = jQuery('#person_fields_conf tr'); |
47 | + | ||
33 | var tr, td2; | 48 | var tr, td2; |
34 | - for ( var i=0; tr=trs[i]; i++ ) { | 49 | + for ( var i=2; tr=trs[i]; i++ ) { |
35 | if ( td2 = tr.getElementsByTagName('td')[1] ) { | 50 | if ( td2 = tr.getElementsByTagName('td')[1] ) { |
36 | - td2.getElementsByTagName('input')[0].onclick(); | 51 | + td2.getElementsByTagName('input')[1].onclick(); |
37 | } | 52 | } |
38 | } | 53 | } |
39 | // --> | 54 | // --> |
@@ -41,7 +56,7 @@ | @@ -41,7 +56,7 @@ | ||
41 | 56 | ||
42 | <div> | 57 | <div> |
43 | <% button_bar do %> | 58 | <% button_bar do %> |
44 | - <%= submit_button('save', _('Save changes')) %> | 59 | + <%= submit_button('save', _('Save changes'), :id=>"save_person_fields") %> |
45 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> | 60 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> |
46 | <% end %> | 61 | <% end %> |
47 | </div> | 62 | </div> |
app/views/features/manage_fields.rhtml
1 | -<%= render :partial => 'manage_person_fields' %> | 1 | +<h1><%= _('Manage fields displayed for profiles') %></h1> |
2 | 2 | ||
3 | -<% if !environment.enabled?('disable_asset_enterprises') %> | ||
4 | - <%= render :partial => 'manage_enterprise_fields' %> | 3 | +<% tabs = [] %> |
4 | +<% tabs << {:title => _("Person's fields"), :id => 'person-fields', | ||
5 | + :content => (render :partial => 'manage_person_fields')} %> | ||
6 | +<% tabs << {:title => _("Community's fields"), :id => 'community-fields', | ||
7 | + :content => (render :partial => 'manage_community_fields')} %> | ||
8 | +<% unless environment.enabled?('disable_asset_enterprises') %> | ||
9 | + <% tabs << {:title => _("Enterprise's fields"), :id => 'enterprise-fields', | ||
10 | + :content => (render :partial => 'manage_enterprise_fields')} %> | ||
5 | <% end %> | 11 | <% end %> |
6 | 12 | ||
7 | -<%= render :partial => 'manage_community_fields' %> | 13 | +<%= render_tabs(tabs) %> |
14 | + | ||
15 | +<%= javascript_include_tag "manage-fields.js" %> |
app/views/users/_users_list.rhtml
@@ -19,16 +19,17 @@ | @@ -19,16 +19,17 @@ | ||
19 | <td class='actions'> | 19 | <td class='actions'> |
20 | <div class="members-buttons-cell"> | 20 | <div class="members-buttons-cell"> |
21 | <% if p.is_admin? %> | 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 | <% else %> | 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 | <% end %> | 25 | <% end %> |
26 | <% if !p.user.activated? %> | 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 | <% else %> | 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 | <% end %> | 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 | </td> | 33 | </td> |
33 | </tr> | 34 | </tr> |
34 | <% end %> | 35 | <% end %> |
@@ -0,0 +1,76 @@ | @@ -0,0 +1,76 @@ | ||
1 | +Feature: check all manage fields | ||
2 | + As an administrator | ||
3 | + I want to check and uncheck all person, enterprise and community's fields | ||
4 | + | ||
5 | + Background: | ||
6 | + Given the following users | ||
7 | + | login | name | | ||
8 | + | mariasilva | Maria Silva | | ||
9 | + And the following enterprises | ||
10 | + | identifier | owner | name | contact_email | contact_phone | enabled | | ||
11 | + | paper-street | mariasilva | Paper Street | marial.silva@workerbees.org | (288) 555-0153 | true | | ||
12 | + And the following community | ||
13 | + | identifier | name | | ||
14 | + | mycommunity | My Community | | ||
15 | + And I am logged in as admin | ||
16 | + And I go to /admin/features/manage_fields | ||
17 | + | ||
18 | + @selenium | ||
19 | + Scenario: check all active person fields | ||
20 | + Given I follow "Person's fields" | ||
21 | + And I check "person_active" | ||
22 | + And I press "save_person_fields" | ||
23 | + When I go to admin_user's control panel | ||
24 | + And I follow "Edit Profile" | ||
25 | + Then I should see "Custom area of study" | ||
26 | + | ||
27 | + @selenium | ||
28 | + Scenario: check all active enterprise fields | ||
29 | + Given I follow "Enterprise's fields" | ||
30 | + And I check "enterprise_active" | ||
31 | + And I press "save_enterprise_fields" | ||
32 | + When I go to paper-street's control panel | ||
33 | + And I follow "Enterprise Info and settings" | ||
34 | + Then I should see "Historic and current context" | ||
35 | + | ||
36 | + @selenium | ||
37 | + Scenario: check all active community fields | ||
38 | + Given I follow "Community's fields" | ||
39 | + And I check "community_active" | ||
40 | + And I press "save_community_fields" | ||
41 | + When I go to mycommunity's control panel | ||
42 | + And I follow "Community Info and settings" | ||
43 | + Then I should see "Economic activity" | ||
44 | + | ||
45 | + @selenium | ||
46 | + Scenario: uncheck Check/Uncheck All active person field | ||
47 | + Given I follow "Person's fields" | ||
48 | + And I check "person_active" | ||
49 | + And I press "save_person_fields" | ||
50 | + And I uncheck "person_active" | ||
51 | + And I press "save_person_fields" | ||
52 | + And I follow "Control panel" | ||
53 | + When I follow "Edit Profile" | ||
54 | + Then I should not see "Custom area of study" | ||
55 | + | ||
56 | + @selenium | ||
57 | + Scenario: uncheck Check/Uncheck All active community field | ||
58 | + Given I follow "Community's fields" | ||
59 | + And I check "community_active" | ||
60 | + And I press "save_community_fields" | ||
61 | + And I uncheck "community_active" | ||
62 | + And I press "save_community_fields" | ||
63 | + When I go to mycommunity's control panel | ||
64 | + And I follow "Community Info and settings" | ||
65 | + Then I should not see "Economic activity" | ||
66 | + | ||
67 | + @selenium | ||
68 | + Scenario: uncheck Check/Uncheck All active enterprise field | ||
69 | + Given I follow "Enterprise's fields" | ||
70 | + And I check "enterprise_active" | ||
71 | + And I press "save_enterprise_fields" | ||
72 | + And I uncheck "enterprise_active" | ||
73 | + And I press "save_enterprise_fields" | ||
74 | + When I go to paper-street's control panel | ||
75 | + And I follow "Enterprise Info and settings" | ||
76 | + Then I should not see "Historic and current context" |
@@ -0,0 +1,47 @@ | @@ -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: remove 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,0 +1,83 @@ | @@ -0,0 +1,83 @@ | ||
1 | +function update_active(name_active, name_required, name_signup) { | ||
2 | + var required = jQuery("input[name='" + name_required + "']")[1] | ||
3 | + var signup = jQuery("input[name='" + name_signup + "']")[1] | ||
4 | + var active = jQuery("input[name='" + name_active + "']")[1] | ||
5 | + | ||
6 | + if(required.checked || signup.checked) | ||
7 | + active.checked = true | ||
8 | +} | ||
9 | + | ||
10 | +function active_action(obj_active, name_required, name_signup) { | ||
11 | + var required = jQuery("input[name='" + name_required + "']")[0] | ||
12 | + var signup = jQuery("input[name='" + name_signup + "']")[0] | ||
13 | + | ||
14 | + required.disabled = signup.disabled = !obj_active.checked | ||
15 | +} | ||
16 | + | ||
17 | +function required_action(name_active, name_required, name_signup) { | ||
18 | + var obj_required = jQuery("input[name='" + name_required + "']")[1] | ||
19 | + | ||
20 | + if(obj_required.checked) { | ||
21 | + jQuery("input[name='" + name_signup + "']")[0].checked = true | ||
22 | + jQuery("input[name='" + name_signup + "']")[1].checked = true | ||
23 | + } | ||
24 | + | ||
25 | + update_active(name_active, name_required, name_signup) | ||
26 | +} | ||
27 | + | ||
28 | +function signup_action(name_active, name_required, name_signup) { | ||
29 | + var obj_signup = jQuery("input[name='" + name_signup + "']")[1] | ||
30 | + | ||
31 | + if(!obj_signup.checked) { | ||
32 | + jQuery("input[name='" + name_required + "']")[0].checked = false | ||
33 | + jQuery("input[name='" + name_required + "']")[1].checked = false | ||
34 | + } | ||
35 | + | ||
36 | + update_active(name_active, name_required, name_signup) | ||
37 | +} | ||
38 | + | ||
39 | + | ||
40 | +jQuery(document).ready(function(){ | ||
41 | + function check_fields(check, table_id, start) { | ||
42 | + var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") | ||
43 | + for (var i = start; i < checkboxes.length; i+=3) { | ||
44 | + checkboxes[i].checked = check | ||
45 | + } | ||
46 | + } | ||
47 | + | ||
48 | + function verify_checked(fields_id){ | ||
49 | + var checkboxes = jQuery("#" + fields_id + "_fields_conf tbody tr td input[type='checkbox']") | ||
50 | + for (var i = 2; i >= 0; i--) { | ||
51 | + var allchecked = true | ||
52 | + for (var j = i+3; j < checkboxes.length; j+=3) { | ||
53 | + if(!checkboxes[j].checked) { | ||
54 | + allchecked = false | ||
55 | + break | ||
56 | + } | ||
57 | + } | ||
58 | + | ||
59 | + var checkbox = jQuery(checkboxes[i+3]).attr("id").split("_") | ||
60 | + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", allchecked) | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + function check_all(fields_id) { | ||
65 | + jQuery("#" + fields_id + "_active").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 0)}) | ||
66 | + jQuery("#" + fields_id + "_required").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 1)}) | ||
67 | + jQuery("#" + fields_id +"_signup").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 2)}) | ||
68 | + verify_checked(fields_id) | ||
69 | + } | ||
70 | + | ||
71 | + check_all("person") | ||
72 | + check_all("enterprise") | ||
73 | + check_all("community") | ||
74 | + | ||
75 | + jQuery("input[type='checkbox']").click(function (){ | ||
76 | + var checkbox = jQuery(this).attr("id").split("_") | ||
77 | + verify_checked(checkbox.first()) | ||
78 | + | ||
79 | + if(this.checked == false) { | ||
80 | + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false) | ||
81 | + } | ||
82 | + }) | ||
83 | +}) |
public/stylesheets/application.css
@@ -4214,6 +4214,11 @@ h1#agenda-title { | @@ -4214,6 +4214,11 @@ h1#agenda-title { | ||
4214 | display: block; | 4214 | display: block; |
4215 | float: left; | 4215 | float: left; |
4216 | } | 4216 | } |
4217 | + | ||
4218 | +.actions .members-buttons-cell { | ||
4219 | + width : 100px | ||
4220 | +} | ||
4221 | + | ||
4217 | .controller-profile_members .msie6 .button-bar a { | 4222 | .controller-profile_members .msie6 .button-bar a { |
4218 | position: relative; | 4223 | position: relative; |
4219 | } | 4224 | } |
@@ -6506,3 +6511,15 @@ ul.article-versions li { | @@ -6506,3 +6511,15 @@ ul.article-versions li { | ||
6506 | font-size: 13px; | 6511 | font-size: 13px; |
6507 | padding: 3px 0px; | 6512 | padding: 3px 0px; |
6508 | } | 6513 | } |
6514 | + | ||
6515 | +/* * * Admin manage fields * * */ | ||
6516 | + | ||
6517 | +.controller-features .manage-fields-batch-actions, | ||
6518 | +.controller-features .manage-fields-batch-actions:hover { | ||
6519 | + border-bottom:solid 2px #000; | ||
6520 | + background-color: #EEE; | ||
6521 | +} | ||
6522 | + | ||
6523 | +.controller-features .manage-fields-batch-actions td { | ||
6524 | + font-style: italic; | ||
6525 | +} |
test/functional/users_controller_test.rb
@@ -133,4 +133,20 @@ class UsersControllerTest < ActionController::TestCase | @@ -133,4 +133,20 @@ class UsersControllerTest < ActionController::TestCase | ||
133 | assert_equal 'name;email', @response.body.split("\n")[0] | 133 | assert_equal 'name;email', @response.body.split("\n")[0] |
134 | end | 134 | end |
135 | 135 | ||
136 | + should 'be able to remove a person' do | ||
137 | + person = fast_create(Person, :environment_id => environment.id) | ||
138 | + assert_difference Person, :count, -1 do | ||
139 | + post :destroy_user, :id => person.id | ||
140 | + end | ||
141 | + end | ||
142 | + | ||
143 | + should 'not crash if user does not exist' do | ||
144 | + person = fast_create(Person) | ||
145 | + | ||
146 | + assert_no_difference Person, :count do | ||
147 | + post :destroy_user, :id => 99999 | ||
148 | + end | ||
149 | + assert_redirected_to :action => 'index' | ||
150 | + end | ||
151 | + | ||
136 | end | 152 | end |