Skip to content

Commit

Permalink
Deployment (#11)
Browse files Browse the repository at this point in the history
Fixed the typo in the migration file which had resulted in the duplication of the username columns.
  • Loading branch information
brwali authored Nov 2, 2024
1 parent 47b0827 commit 00279cf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
9 changes: 5 additions & 4 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
#
Expand All @@ -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
Expand Down
31 changes: 19 additions & 12 deletions app/views/users/list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@
<input type='submit' value='Edit'/>
<% 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 %>

<div class="exp">
<table>
<tr><th colspan=5></th><th colspan=3 class="head">E-mail on ...</th></tr>
<tr><th class="head">User Name</th><th class="head">Full Name</th><th class="head">Email Address</th><th class="head">Role</th><th class="head">Parent</th><th class="head">Review</th><th class="head">Submission</th><th class="head">Meta-review</th><th class="head">Delete</th></tr>
<tr>
<th class="head">User Name</th>
<th class="head">Full Name</th>
<th class="head">Email Address</th>
<th class="head">Role</th>
<th class="head">Parent</th>
<th class="head">Review</th>
<th class="head">Submission</th>
<th class="head">Meta-review</th>
<th class="head">Delete</th>
</tr>
<% @paginated_users.each do |user| %>
<% if (params[:show] != 'true' && !user.username(session[:ip]).include?("_hidden")) || params[:show] == 'true'%>
<tr class="exp">
Expand All @@ -35,10 +47,6 @@
<% end -%>
</table>
</div>
<hr/>

<hr/>
<%#= render :partial => 'shared_scripts/pages' %>

<div style="float: left; display: inline-block;">
<%= will_paginate @paginated_users, :inner_window => 1, :outer_window => 1, :params => {:num_versions => @per_page}%>
Expand All @@ -53,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&nbsp;&nbsp;|&nbsp;&nbsp;full name (first [middle] last)&nbsp;&nbsp;|&nbsp;&nbsp;e-mail address' %> |
<%= link_to 'Export users', :controller=>'export_file',:action=>'start',:model=> 'User',:id=> 1 %>

</p>
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 00279cf

Please sign in to comment.