From d77b5aa272e280ae9e19173adbfb9836a15e5a4b Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 28 Oct 2024 21:07:33 -0400 Subject: [PATCH] fix: fixed user error in team and updated code style for paginate options --- app/controllers/users_controller.rb | 11 ++++++++++- app/models/team.rb | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 71aaa9cde72..92c852f9c15 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -247,9 +247,18 @@ def role end end + def pagination_options + { + '1' => 25, + '2' => 50, + '3' => 100, + '4' => User.count + } + end + # For filtering the users list with proper search and pagination. def paginate_list - paginate_options = { '1' => 25, '2' => 50, '3' => 100, '4' => User.count} + 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/models/team.rb b/app/models/team.rb index 447eb6e3b43..21c97b9d8c3 100755 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -78,8 +78,7 @@ def full? # Add member to the team, changed to hash by E1776 def add_member(user, _assignment_id = nil) - username = user.respond_to?(:username) ? user.username : user.name - raise "The user #{username} is already a member of the team #{name}" if user?(user) + raise "The user #{user.username} is already a member of the team #{name}" if user?(user) can_add_member = false unless full? @@ -88,7 +87,7 @@ def add_member(user, _assignment_id = nil) parent = TeamNode.find_by(node_object_id: id) TeamUserNode.create(parent_id: parent.id, node_object_id: t_user.id) add_participant(parent_id, user) - ExpertizaLogger.info LoggerMessage.new('Model:Team', username, "Added member to the team #{id}") + ExpertizaLogger.info LoggerMessage.new('Model:Team', user.username, "Added member to the team #{id}") end can_add_member end