From 00279cfe197b860b2ca4dbf54eda72f2fcac1f0e Mon Sep 17 00:00:00 2001 From: brwali <144480335+brwali@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:18:57 -0400 Subject: [PATCH] Deployment (#11) Fixed the typo in the migration file which had resulted in the duplication of the username columns. --- app/controllers/users_controller.rb | 9 +++--- app/views/users/list.html.erb | 31 ++++++++++++------- ...42307_rename_name_and_fullname_in_users.rb | 2 +- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 92c852f9c15..780ce0887a7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -63,6 +63,8 @@ def set_anonymized_view 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 @@ -259,7 +261,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 # @@ -270,15 +271,15 @@ 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 = params[:per_page] || '4' + # 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] # 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 57422087b6b..f2f7731119a 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -6,18 +6,30 @@ <% 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], ['Full name', 2], ['Email', 3]])) %> -<%= submit_tag("Search") %> -<% 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") %> -<%= render :partial => 'links' %> +<%= label_tag :per_page, 'Users per page: ' %> + <%= 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 %>
E-mail on ... | ||||||||
---|---|---|---|---|---|---|---|---|
User Name | Full Name | Email Address | Role | Parent | Review | Submission | Meta-review | Delete |
User Name | +Full Name | +Email Address | +Role | +Parent | +Review | +Submission | +Meta-review | +Delete | +