From e32d1fa2d4767618de871916a0ee6d704b667a7a Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 18:27:16 -0400 Subject: [PATCH 01/11] fixed migration issue --- db/migrate/20241009142307_rename_name_and_fullname_in_users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb index 2be1fe111f1..007628b6e8b 100644 --- a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb +++ b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb @@ -3,6 +3,6 @@ def change rename_column :users, :name, :username rename_column :account_requests, :name, :username rename_column :users, :fullname, :name - rename_column :account_requests, :fullname, :username + rename_column :account_requests, :fullname, :name end end \ No newline at end of file From df635bd4028c40e7c3638931c325493ac7244668 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 18:49:30 -0400 Subject: [PATCH 02/11] change deployment to default to only show 100 users --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 92c852f9c15..a2a4e57ffc7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -271,7 +271,7 @@ def paginate_list # Sets the number of users to display per page based on the 'per_page' parameter from the request. # If no 'per_page' parameter is provided, it defaults to '4', which corresponds to displaying all users on one page. - @per_page = params[:per_page] || '4' + @per_page = params[:per_page] || '3' # search for corresponding users # users = User.search_users(role, user_id, letter, @search_by) From c08b6089eecdeba768bbfd4a683c966060c2ddad Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 18:50:25 -0400 Subject: [PATCH 03/11] fixed deployment --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a2a4e57ffc7..4f037de8a44 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -271,7 +271,7 @@ def paginate_list # Sets the number of users to display per page based on the 'per_page' parameter from the request. # If no 'per_page' parameter is provided, it defaults to '4', which corresponds to displaying all users on one page. - @per_page = params[:per_page] || '3' + @per_page = '3' # search for corresponding users # users = User.search_users(role, user_id, letter, @search_by) From 642a3f7d76a4b9c9e0d7a89035a70edf7e2567e2 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 19:29:41 -0400 Subject: [PATCH 04/11] added html elements for pagination --- app/controllers/users_controller.rb | 4 ++-- app/views/users/list.html.erb | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4f037de8a44..86e6ad8ad3a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -270,8 +270,8 @@ def paginate_list @search_by = params[:search_by] # Sets the number of users to display per page based on the 'per_page' parameter from the request. - # If no 'per_page' parameter is provided, it defaults to '4', which corresponds to displaying all users on one page. - @per_page = '3' + # If no 'per_page' parameter is provided, it defaults to '3', which corresponds to displaying all users on one page. + @per_page = params[:per_page] || '3' # search for corresponding users # users = User.search_users(role, user_id, letter, @search_by) diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 57422087b6b..177bf7391f0 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -8,16 +8,22 @@ <%= form_tag :action => 'list', :paginate_show => '1', :num_users => @per_page do %> <%= label_tag :letter, 'Search users: ' %><%= text_field_tag(:letter,params[:letter]) %> -<%= select_tag(:search_by, options_for_select([['Username', 1], ['Full name', 2], ['Email', 3]])) %> +<%= select_tag(:search_by, options_for_select([['Username', 1], ['Name', 2], ['Email', 3]])) %> <%= submit_tag("Search") %> <% end %> +<%= form_tag :action => 'list', :paginate_show => '1', :num_users => @per_page do %> + <%= label_tag :letter, 'Number of users displayed per page' %><%= text_field_tag(:letter,params[:per_page]) %> +<%= select_tag(:search_by, options_for_select([['25 users', 1], ['50 users', 2], ['100 users', 3], ['All users', 4]])) %> +<%= submit_tag("List") %> +<% end %> + <%= render :partial => 'links' %>
- + <% @paginated_users.each do |user| %> <% if (params[:show] != 'true' && !user.username(session[:ip]).include?("_hidden")) || params[:show] == 'true'%> From 40e97811b29491ab499fc10fe6df9ee1b07a9698 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 19:43:45 -0400 Subject: [PATCH 05/11] changed the pagination view --- app/views/users/list.html.erb | 45 ++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 177bf7391f0..472b1ea21b6 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -1,29 +1,35 @@

Manage users


-<%= form_tag :action => 'show_if_authorized' do %> - View user - enter exact login: <%= text_field_with_auto_complete :user, :username, {:size => 41} %> - -<% end %> - -<%= form_tag :action => 'list', :paginate_show => '1', :num_users => @per_page do %> - <%= label_tag :letter, 'Search users: ' %><%= text_field_tag(:letter,params[:letter]) %> -<%= select_tag(:search_by, options_for_select([['Username', 1], ['Name', 2], ['Email', 3]])) %> -<%= submit_tag("Search") %> -<% end %> +<%= form_tag :action => 'list', method: :get, id: 'pagination_form' do %> + <%= label_tag :letter, 'Search users: ' %><%= text_field_tag(:letter, params[:letter]) %> + <%= select_tag(:search_by, options_for_select([['Username', 1], ['Full name', 2], ['Email', 3]])) %> + <%= submit_tag("Search") %> -<%= form_tag :action => 'list', :paginate_show => '1', :num_users => @per_page do %> - <%= label_tag :letter, 'Number of users displayed per page' %><%= text_field_tag(:letter,params[:per_page]) %> -<%= select_tag(:search_by, options_for_select([['25 users', 1], ['50 users', 2], ['100 users', 3], ['All users', 4]])) %> -<%= submit_tag("List") %> +

+ + <%= select_tag(:per_page, options_for_select( + [['25 users', '1'], ['50 users', '2'], ['100 users', '3'], ['All users', '4']], + selected: @per_page + ), + onchange: "document.getElementById('pagination_form').submit();" + ) %> <% end %> -<%= render :partial => 'links' %> -
E-mail on ...
User NameFull NameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
User NameNameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
- + + + + + + + + + + + <% @paginated_users.each do |user| %> <% if (params[:show] != 'true' && !user.username(session[:ip]).include?("_hidden")) || params[:show] == 'true'%> @@ -41,10 +47,6 @@ <% end -%>
E-mail on ...
User NameNameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
User NameFull NameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
-
- -
-<%#= render :partial => 'shared_scripts/pages' %>
<%= will_paginate @paginated_users, :inner_window => 1, :outer_window => 1, :params => {:num_versions => @per_page}%> @@ -59,5 +61,4 @@ <%= link_to 'New user',:role => "Student", :action => 'new' %> | <%= link_to 'Import users', :controller=>'import_file', :action=>'start', :model => 'User', :expected_fields => 'username  |  full name (first [middle] last)  |  e-mail address' %> | <%= link_to 'Export users', :controller=>'export_file',:action=>'start',:model=> 'User',:id=> 1 %> -

From 33d422f1ddf56f0545f2777e383b872c8d0225f9 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 19:52:25 -0400 Subject: [PATCH 06/11] visual fix for pagination --- app/controllers/users_controller.rb | 2 +- app/views/users/list.html.erb | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 86e6ad8ad3a..6316fa0cf30 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -63,6 +63,7 @@ def set_anonymized_view def list letter = params[:letter] search_by = params[:search_by] + @pagination_options = pagination_options # If search parameters present if letter.present? && search_by.present? case search_by.to_i @@ -259,7 +260,6 @@ def pagination_options # For filtering the users list with proper search and pagination. def paginate_list paginate_options = pagination_options - # If the above hash does not have a value for the key, # it means that we need to show all the users on the page # diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 472b1ea21b6..d89a94d5f74 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -1,19 +1,20 @@

Manage users


-<%= form_tag :action => 'list', method: :get, id: 'pagination_form' do %> - <%= label_tag :letter, 'Search users: ' %><%= text_field_tag(:letter, params[:letter]) %> +<%= form_tag :action => 'show_if_authorized' do %> + View user - enter exact login: <%= text_field_with_auto_complete :user, :username, {:size => 41} %> + +<% end %> + +<%= form_tag :action => 'list' do %> + <%= label_tag :letter, 'Search users: ' %> + <%= text_field_tag(:letter, params[:letter]) %> <%= select_tag(:search_by, options_for_select([['Username', 1], ['Full name', 2], ['Email', 3]])) %> <%= submit_tag("Search") %> -

- - <%= select_tag(:per_page, options_for_select( - [['25 users', '1'], ['50 users', '2'], ['100 users', '3'], ['All users', '4']], - selected: @per_page - ), - onchange: "document.getElementById('pagination_form').submit();" - ) %> + <%= label_tag :per_page, 'Users per page: ' %> + <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page] || '3')) %> + <%= submit_tag("Apply", name: nil) %> <% end %>
From 2f75efc13e242b9fa9f771dbe33ce078c3f0bc35 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 19:55:52 -0400 Subject: [PATCH 07/11] fixed visuals for pagination --- app/views/users/list.html.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index d89a94d5f74..b3675b523ed 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -12,9 +12,8 @@ <%= select_tag(:search_by, options_for_select([['Username', 1], ['Full name', 2], ['Email', 3]])) %> <%= submit_tag("Search") %> - <%= label_tag :per_page, 'Users per page: ' %> - <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page] || '3')) %> - <%= submit_tag("Apply", name: nil) %> +<%= label_tag :per_page, 'Users per page: ' %> + <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page]), onchange: 'this.form.submit()') %> <% end %>
From 15a86351f8f137d231b100a51b09df02cbcc6cf5 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 20:06:13 -0400 Subject: [PATCH 08/11] fixed visual error on user pagination --- app/controllers/users_controller.rb | 16 ++++++++-------- app/views/users/list.html.erb | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6316fa0cf30..8e43c8250bb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -249,12 +249,12 @@ def role end def pagination_options - { - '1' => 25, - '2' => 50, - '3' => 100, - '4' => User.count - } + [ + ['25', 25], + ['50', 50], + ['100', 100], + ['All', User.count] + ] end # For filtering the users list with proper search and pagination. @@ -270,8 +270,8 @@ def paginate_list @search_by = params[:search_by] # Sets the number of users to display per page based on the 'per_page' parameter from the request. - # If no 'per_page' parameter is provided, it defaults to '3', which corresponds to displaying all users on one page. - @per_page = params[:per_page] || '3' + # If no 'per_page' parameter is provided, it defaults to '2', which corresponds to displaying 50 users on one page. + @per_page = params[:per_page] || '2' # search for corresponding users # users = User.search_users(role, user_id, letter, @search_by) diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index b3675b523ed..4a91afbf0bc 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -13,7 +13,7 @@ <%= submit_tag("Search") %> <%= label_tag :per_page, 'Users per page: ' %> - <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page]), onchange: 'this.form.submit()') %> + <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page] || '25'), onchange: 'this.form.submit()') %> <% end %>
From ad2c9f2999e126757a145f03625797498c12be76 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 20:08:22 -0400 Subject: [PATCH 09/11] revised view bug --- app/controllers/users_controller.rb | 2 +- app/views/users/list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8e43c8250bb..49f64fd07f5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -271,7 +271,7 @@ def paginate_list # Sets the number of users to display per page based on the 'per_page' parameter from the request. # If no 'per_page' parameter is provided, it defaults to '2', which corresponds to displaying 50 users on one page. - @per_page = params[:per_page] || '2' + @per_page = params[:per_page] || 25 # search for corresponding users # users = User.search_users(role, user_id, letter, @search_by) diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 4a91afbf0bc..6b7e351bf9c 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -13,7 +13,7 @@ <%= submit_tag("Search") %> <%= label_tag :per_page, 'Users per page: ' %> - <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page] || '25'), onchange: 'this.form.submit()') %> + <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page] || 25), onchange: 'this.form.submit()') %> <% end %>
From f1750e46184c9645d457ab87647b9072b14274ba Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 20:13:20 -0400 Subject: [PATCH 10/11] revised view error --- app/controllers/users_controller.rb | 17 +++++++++-------- app/views/users/list.html.erb | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 49f64fd07f5..780ce0887a7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -64,6 +64,7 @@ def list letter = params[:letter] search_by = params[:search_by] @pagination_options = pagination_options + @per_page = @pagination_options[params[:per_page]] # If search parameters present if letter.present? && search_by.present? case search_by.to_i @@ -249,12 +250,12 @@ def role end def pagination_options - [ - ['25', 25], - ['50', 50], - ['100', 100], - ['All', User.count] - ] + { + '1' => 25, + '2' => 50, + '3' => 100, + '4' => User.count + } end # For filtering the users list with proper search and pagination. @@ -271,14 +272,14 @@ def paginate_list # Sets the number of users to display per page based on the 'per_page' parameter from the request. # If no 'per_page' parameter is provided, it defaults to '2', which corresponds to displaying 50 users on one page. - @per_page = params[:per_page] || 25 + @per_page = params[:per_page] # search for corresponding users # users = User.search_users(role, user_id, letter, @search_by) # paginate users = if paginate_options[@per_page.to_s].nil? # displaying all - no pagination - User.paginate(page: params[:page], per_page: User.count) + User.paginate(page: params[:page], per_page: paginate_options['1']) else # some pagination is active - use the per_page User.paginate(page: params[:page], per_page: paginate_options[@per_page.to_s]) end diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 6b7e351bf9c..f2f7731119a 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -13,7 +13,7 @@ <%= submit_tag("Search") %> <%= label_tag :per_page, 'Users per page: ' %> - <%= select_tag(:per_page, options_for_select(@pagination_options, selected: params[:per_page] || 25), onchange: 'this.form.submit()') %> + <%= select_tag(:per_page, options_for_select(@pagination_options.map { |key, value| ["#{value == User.count ? 'All' : value}", key] }, selected: params[:per_page] || '1'), onchange: 'this.form.submit()') %> <% end %>
From 404233bb8424d4785a9fcf137974943d10f63b1b Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 1 Nov 2024 20:27:06 -0400 Subject: [PATCH 11/11] changed num_version to per_page --- app/views/users/list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index f2f7731119a..52c42b5cd3b 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -49,7 +49,7 @@
- <%= will_paginate @paginated_users, :inner_window => 1, :outer_window => 1, :params => {:num_versions => @per_page}%> + <%= will_paginate @paginated_users, inner_window: 1, outer_window: 1, params: { per_page: params[:per_page] } %>