diff --git a/.travis.yml b/.travis.yml
index abda708fe78..af85ede5ad9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,7 +58,7 @@ after_script:
- ls -lah coverage/
- cd $HOME
- git config --global user.email "zhu6@ncsu.edu"
- - git config --global user.name "Winbobob"
+ - git config --global user.username "Winbobob"
- git clone --quiet https://$TOKEN@github.com/expertiza/$REPORT_REPO_NAME.git
- cd $REPORT_REPO_NAME
- if [ ! -d "./$TRAVIS_PULL_REQUEST" ]; then mkdir $TRAVIS_PULL_REQUEST; fi
diff --git a/app/controllers/account_request_controller.rb b/app/controllers/account_request_controller.rb
index 396dbe1ac79..88755b98f3e 100644
--- a/app/controllers/account_request_controller.rb
+++ b/app/controllers/account_request_controller.rb
@@ -37,7 +37,7 @@ def create_approved_user
if requested_user.status.nil?
flash[:error] = 'Please Approve or Reject before submitting'
elsif requested_user.update_attributes(requested_user_params)
- flash[:success] = "The user \"#{requested_user.name}\" has been successfully updated."
+ flash[:success] = "The user \"#{requested_user.username}\" has been successfully updated."
end
# If the users request is approved, they are stored as a user in the database
if requested_user.status == 'Approved'
@@ -47,7 +47,7 @@ def create_approved_user
elsif requested_user.status == 'Rejected'
# If the user request has been rejected, a flash message is shown and redirected to review page
if requested_user.update_columns(status: is_approved)
- flash[:success] = "The user \"#{requested_user.name}\" has been Rejected."
+ flash[:success] = "The user \"#{requested_user.username}\" has been Rejected."
# redirect_to action: 'list_pending_requested'
# return
else
@@ -61,7 +61,7 @@ def create_approved_user
# Creates a new user if their request is approved
def user_new(requested_user)
new_user = User.new
- new_user.name = requested_user.name
+ new_user.username = requested_user.username
new_user.role_id = requested_user.role_id
new_user.institution_id = requested_user.institution_id
new_user.fullname = requested_user.fullname
@@ -75,7 +75,7 @@ def user_new(requested_user)
prepared_mail = MailerHelper.send_mail_to_user(new_user, 'Your Expertiza account and password have been created.', 'user_welcome', password)
prepared_mail.deliver_now
flash[:success] = "A new password has been sent to new user's e-mail address."
- undo_link("The user \"#{requested_user.name}\" has been successfully created. ")
+ undo_link("The user \"#{requested_user.username}\" has been successfully created. ")
else
foreign
end
@@ -108,7 +108,7 @@ def list_pending_requested
def create_requested_user_record
requested_user = AccountRequest.new(requested_user_params)
# An object is created with respect to AccountRequest model inorder to populate the users information when account is requested
- (user_exists = User.find_by(name: requested_user.name)) || User.find_by(name: requested_user.email)
+ (user_exists = User.find_by(username: requested_user.username)) || User.find_by(username: requested_user.email)
requested_user_saved = save_requested_user(requested_user, params)
# Stores a boolean value with respect to whether the user data is saved or not
if !user_exists && requested_user_saved
@@ -122,7 +122,7 @@ def create_requested_user_record
flash[:error] = requested_user.errors.full_messages.to_sentence
# If saving in the AccountRequests model has failed
end
- ExpertizaLogger.error LoggerMessage.new(controller_name, requested_user.name, flash[:error], request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, requested_user.username, flash[:error], request)
redirect_to controller: 'account_request', action: 'new', role: 'Student'
# if the first if clause fails, redirect back to the account requests page!
end
@@ -152,8 +152,8 @@ def notify_supers_new_request(requested_user)
prepared_mail.deliver
end
# Notifying an email to the administrator regarding the new user request!
- ExpertizaLogger.info LoggerMessage.new(controller_name, requested_user.name, 'The account you are requesting has been created successfully.', request)
- flash[:success] = "User signup for \"#{requested_user.name}\" has been successfully requested."
+ ExpertizaLogger.info LoggerMessage.new(controller_name, requested_user.username, 'The account you are requesting has been created successfully.', request)
+ flash[:success] = "User signup for \"#{requested_user.username}\" has been successfully requested."
# Print out the acknowledgement message to the user and redirect to /instructors/home page when successful
end
@@ -163,7 +163,7 @@ def roles_for_request_sign_up
end
def requested_user_params
- params.require(:user).permit(:name, :role_id, :fullname, :institution_id, :email)
+ params.require(:user).permit(:username, :role_id, :fullname, :institution_id, :email)
.merge(self_introduction: params[:requested_user][:self_introduction])
end
end
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 780bd00d2a3..e38d96443cb 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -22,7 +22,7 @@ def show_super_administrator
end
def list_administrators
- @users = User.admins.order(:name).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50)
+ @users = User.admins.order(:username).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50)
end
def show_administrator
@@ -31,7 +31,7 @@ def show_administrator
end
def list_instructors
- @users = User.instructors.order(:name).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50)
+ @users = User.instructors.order(:username).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50)
end
def show_instructor
diff --git a/app/controllers/advertise_for_partner_controller.rb b/app/controllers/advertise_for_partner_controller.rb
index 5c98196e5c3..a05960a4944 100644
--- a/app/controllers/advertise_for_partner_controller.rb
+++ b/app/controllers/advertise_for_partner_controller.rb
@@ -28,7 +28,7 @@ def create
team = AssignmentTeam.find_by(id: params[:id])
team.update_attributes(advertise_for_partner: true, comments_for_advertisement: params[:comments_for_advertisement])
participant = AssignmentParticipant.find_by(parent_id: team.assignment.id, user_id: session[:user].id)
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your advertisement has been successfully created.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your advertisement has been successfully created.', request)
redirect_to view_student_teams_path student_id: participant.id
end
@@ -41,11 +41,11 @@ def update
@team.update_attributes(comments_for_advertisement: params[:comments_for_advertisement])
participant = AssignmentParticipant.find_by(parent_id: @team.assignment.id, user_id: session[:user].id)
rescue StandardError
- ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'An error occurred and your advertisement was not updated.', request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'An error occurred and your advertisement was not updated.', request)
flash[:error] = 'An error occurred and your advertisement was not updated!'
render action: 'edit'
else
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your advertisement has been successfully updated.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your advertisement has been successfully updated.', request)
flash[:success] = 'Your advertisement was successfully updated!'
redirect_to view_student_teams_path student_id: participant.id
end
@@ -55,11 +55,11 @@ def remove
team.update_attributes(advertise_for_partner: false, comments_for_advertisement: nil)
participant = AssignmentParticipant.find_by(parent_id: team.assignment.id, user_id: session[:user].id)
rescue StandardError
- ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'An error occurred and your advertisement was not removed', request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'An error occurred and your advertisement was not removed', request)
flash[:error] = 'An error occurred and your advertisement was not removed!'
redirect_back fallback_location: root_path
else
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your advertisement has been successfully removed.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your advertisement has been successfully removed.', request)
flash[:success] = 'Your advertisement was successfully removed!'
redirect_to view_student_teams_path student_id: participant.id
end
diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb
index 33e3da8bd30..dda82d289f9 100644
--- a/app/controllers/assignments_controller.rb
+++ b/app/controllers/assignments_controller.rb
@@ -150,10 +150,10 @@ def delete
# FixB : Instrucor will be able to delete any assignment belonging to his/her courses.
if (user.role.name == 'Instructor') || ((user.role.name == 'Teaching Assistant') && (user.id == assignment_form.assignment.instructor_id))
assignment_form.delete(params[:force])
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Assignment #{assignment_form.assignment.id} was deleted.", request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Assignment #{assignment_form.assignment.id} was deleted.", request)
flash[:success] = 'The assignment was successfully deleted.'
else
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'You are not authorized to delete this assignment.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'You are not authorized to delete this assignment.', request)
flash[:error] = 'You are not authorized to delete this assignment.'
end
rescue StandardError => e
@@ -410,7 +410,7 @@ def check_questionnaires_usage
def unassigned_rubrics_warning
if !list_unassigned_rubrics.empty? && request.original_fullpath == "/assignments/#{@assignment_form.assignment.id}/edit"
rubrics_needed = needed_rubrics(list_unassigned_rubrics)
- ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, "Rubrics missing for #{@assignment_form.assignment.name}.", request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, "Rubrics missing for #{@assignment_form.assignment.name}.", request)
if flash.now[:error] != 'Failed to save the assignment: ["Total weight of rubrics should add up to either 0 or 100%"]'
flash.now[:error] = 'You did not specify all the necessary rubrics. You need ' + rubrics_needed +
" of assignment #{@assignment_form.assignment.name} before saving the assignment. You can assign rubrics" \
@@ -445,7 +445,7 @@ def update_assignment_badges
# flash notice if the time zone is not specified for an assignment's due date
def user_timezone_specified
- ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'Timezone not specified', request) if current_user.timezonepref.nil?
+ ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'Timezone not specified', request) if current_user.timezonepref.nil?
flash.now[:error] = 'You have not specified your preferred timezone yet. Please do this before you set up the deadlines.' if current_user.timezonepref.nil?
end
@@ -457,11 +457,11 @@ def key_nonexistent_handler
@assignment.course_id = params[:course_id]
if @assignment.save
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "The assignment was successfully saved: #{@assignment.as_json}", request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "The assignment was successfully saved: #{@assignment.as_json}", request)
flash[:note] = 'The assignment was successfully saved.'
redirect_to list_tree_display_index_path
else
- ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, "Failed assignment: #{@assignment.errors.full_messages.join(' ')}", request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, "Failed assignment: #{@assignment.errors.full_messages.join(' ')}", request)
flash[:error] = "Failed to save the assignment: #{@assignment.errors.full_messages.join(' ')}"
redirect_to edit_assignment_path @assignment.id
end
@@ -501,7 +501,7 @@ def update_feedback_attributes
else
flash[:error] = "Failed to save the assignment: #{@assignment_form.errors}"
end
- ExpertizaLogger.info LoggerMessage.new('', session[:user].name, "The assignment was saved: #{@assignment_form.as_json}", request)
+ ExpertizaLogger.info LoggerMessage.new('', session[:user].username, "The assignment was saved: #{@assignment_form.as_json}", request)
end
def query_participants_and_alert
diff --git a/app/controllers/auth_controller.rb b/app/controllers/auth_controller.rb
index 215d5d977f6..dfa0b8546a9 100644
--- a/app/controllers/auth_controller.rb
+++ b/app/controllers/auth_controller.rb
@@ -19,7 +19,7 @@ def login
if request.get?
AuthController.clear_session(session)
else
- user = User.find_by_login(params[:login][:name])
+ user = User.find_by_login(params[:login][:username])
if user && user.valid_password?(params[:login][:password])
after_login(user)
else
@@ -34,7 +34,7 @@ def login
def after_login(user)
session[:user] = user
session[:impersonate] = false
- ExpertizaLogger.info LoggerMessage.new('', user.name, 'Login successful')
+ ExpertizaLogger.info LoggerMessage.new('', user.username, 'Login successful')
AuthController.set_current_role(user.role_id, session)
redirect_to controller: AuthHelper.get_home_controller(session[:user]),
action: AuthHelper.get_home_action(session[:user])
diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb
index d0fd52621a0..dc0da766adb 100644
--- a/app/controllers/bookmarks_controller.rb
+++ b/app/controllers/bookmarks_controller.rb
@@ -32,10 +32,10 @@ def create
params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')
begin
Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your bookmark has been successfully created!', request)
flash[:success] = 'Your bookmark has been successfully created!'
rescue StandardError
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, $ERROR_INFO, request)
flash[:error] = $ERROR_INFO
end
redirect_to action: 'list', id: params[:topic_id]
@@ -48,7 +48,7 @@ def edit
def update
@bookmark = Bookmark.find(params[:id])
@bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your bookmark has been successfully updated!', request)
flash[:success] = 'Your bookmark has been successfully updated!'
redirect_to action: 'list', id: @bookmark.topic_id
end
@@ -56,7 +56,7 @@ def update
def destroy
@bookmark = Bookmark.find(params[:id])
@bookmark.destroy
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your bookmark has been successfully deleted!', request)
flash[:success] = 'Your bookmark has been successfully deleted!'
redirect_to action: 'list', id: @bookmark.topic_id
end
diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb
index 80c69c6505a..4fbd8369ea9 100644
--- a/app/controllers/conference_controller.rb
+++ b/app/controllers/conference_controller.rb
@@ -51,10 +51,10 @@ def create
def add_conference_user
# check if user is already present with given username in system
- existing_user = User.find_by(name: params[:user][:name])
+ existing_user = User.find_by(username: params[:user][:username])
# if user exist then add user as participant to assignment else create account and then add as participant
if existing_user.nil?
- if !User.find_by(email: params[:user][:email]).nil? || (params[:user][:name].nil? || params[:user][:name].empty?)
+ if !User.find_by(email: params[:user][:email]).nil? || (params[:user][:username].nil? || params[:user][:username].empty?)
flash[:error] = 'A user with username of this email already exists, Please provide a unique email to continue.'
# redirect_to request.referrer
return false
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index dafd7019f70..f0922d83d48 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -16,9 +16,9 @@ def action_allowed?
end
def auto_complete_for_user_name
- search = params[:user][:name].to_s
+ search = params[:user][:username].to_s
@users = User.where(role_id: 6) if search.present?
- render inline: "<%= auto_complete_result @users, 'name' %>", layout: false
+ render inline: "<%= auto_complete_result @users, 'username' %>", layout: false
end
# Creates a new course
@@ -121,18 +121,18 @@ def view_teaching_assistants
# Adds a teaching assistant to a course
def add_ta
@course = Course.find(params[:course_id])
- @user = User.find_by(name: params[:user][:name])
+ @user = User.find_by(username: params[:user][:username])
if @user.nil?
- flash.now[:error] = 'The user inputted "' + params[:user][:name] + '" does not exist.'
+ flash.now[:error] = 'The user inputted "' + params[:user][:username] + '" does not exist.'
elsif !TaMapping.where(ta_id: @user.id, course_id: @course.id).empty?
- flash.now[:error] = 'The user inputted "' + params[:user][:name] + '" is already a TA for this course.'
+ flash.now[:error] = 'The user inputted "' + params[:user][:username] + '" is already a TA for this course.'
else
@ta_mapping = TaMapping.create(ta_id: @user.id, course_id: @course.id)
@user.role = Role.find_by name: 'Teaching Assistant'
@user.save
@course = @ta_mapping
- undo_link("The TA \"#{@user.name}\" has been successfully added.")
+ undo_link("The TA \"#{@user.username}\" has been successfully added.")
end
render action: 'add_ta.js.erb', layout: false
end
@@ -151,7 +151,7 @@ def remove_ta
@ta_mapping.destroy
@course = @ta_mapping
- undo_link("The TA \"#{@ta.name}\" has been successfully removed.")
+ undo_link("The TA \"#{@ta.username}\" has been successfully removed.")
render action: 'remove_ta.js.erb', layout: false
end
diff --git a/app/controllers/export_file_controller.rb b/app/controllers/export_file_controller.rb
index 83bf7f368ca..0b56b08cf39 100644
--- a/app/controllers/export_file_controller.rb
+++ b/app/controllers/export_file_controller.rb
@@ -103,7 +103,7 @@ def export_advices
end
def export_tags
- @user_ids = User.where('name IN (?)', params[:names])
+ @user_ids = User.where('username IN (?)', params[:names])
@students = AnswerTag.select('answers.*, answer_tags.*').joins(:answer).where('answer_tags.answer_id = answers.id and answer_tags.user_id IN (?)', @user_ids.pluck(:id))
attributes = %w[user_id tag_prompt_deployment_id comments value]
diff --git a/app/controllers/grades_controller.rb b/app/controllers/grades_controller.rb
index 1da0687f6b9..3ba0bdd0ac6 100644
--- a/app/controllers/grades_controller.rb
+++ b/app/controllers/grades_controller.rb
@@ -160,9 +160,9 @@ def update
unless format('%.2f', total_score) == params[:participant][:grade]
participant.update_attribute(:grade, params[:participant][:grade])
message = if participant.grade.nil?
- 'The computed score will be used for ' + participant.user.name + '.'
+ 'The computed score will be used for ' + participant.user.username + '.'
else
- 'A score of ' + params[:participant][:grade] + '% has been saved for ' + participant.user.name + '.'
+ 'A score of ' + params[:participant][:grade] + '% has been saved for ' + participant.user.username + '.'
end
end
flash[:note] = message
diff --git a/app/controllers/impersonate_controller.rb b/app/controllers/impersonate_controller.rb
index f32f7cf909c..8dd3d5505f4 100644
--- a/app/controllers/impersonate_controller.rb
+++ b/app/controllers/impersonate_controller.rb
@@ -27,8 +27,8 @@ def action_allowed?
# This function does not seem to work
def auto_complete_for_user_name
- @users = session[:user].get_available_users(params[:user][:name])
- render inline: "<%= auto_complete_result @users, 'name' %>", layout: false
+ @users = session[:user].get_available_users(params[:user][:username])
+ render inline: "<%= auto_complete_result @users, 'username' %>", layout: false
end
# Called whenever we want to enter the impersonate mode in the application.
@@ -56,11 +56,11 @@ def generate_session(user)
def overwrite_session
if params[:impersonate].nil?
- user = real_user(params[:user][:name])
+ user = real_user(params[:user][:username])
session[:super_user] = session[:user] if session[:super_user].nil?
generate_session(user)
- elsif !params[:impersonate][:name].empty?
- user = real_user(params[:impersonate][:name])
+ elsif !params[:impersonate][:username].empty?
+ user = real_user(params[:impersonate][:username])
generate_session(user)
else
session[:user] = session[:super_user]
@@ -75,7 +75,7 @@ def overwrite_session
# warn_for_special_chars takes the output from above method and flashes an error if there are any special characters(/\?<>|&$#) in the string
def check_if_input_is_valid
- if params[:user] && warn_for_special_chars(params[:user][:name], 'Username')
+ if params[:user] && warn_for_special_chars(params[:user][:username], 'Username')
flash[:error] = 'Please enter valid user name'
redirect_back fallback_location: root_path
elsif params[:impersonate] && warn_for_special_chars(params[:impersonate][:name], 'Username')
@@ -92,16 +92,16 @@ def check_if_input_is_valid
def check_if_user_impersonateable
if params[:impersonate].nil?
- user = real_user(params[:user][:name])
+ user = real_user(params[:user][:username])
unless @original_user.can_impersonate? user
- @message = "You cannot impersonate '#{params[:user][:name]}'."
+ @message = "You cannot impersonate '#{params[:user][:username]}'."
temp
AuthController.clear_user_info(session, nil)
else
overwrite_session
end
else
- unless params[:impersonate][:name].empty?
+ unless params[:impersonate][:username].empty?
overwrite_session
end
end
@@ -115,14 +115,14 @@ def impersonate
begin
@original_user = session[:super_user] || session[:user]
if params[:impersonate].nil?
- @message = "You cannot impersonate '#{params[:user][:name]}'."
- @message = 'User name cannot be empty' if params[:user][:name].empty?
- user = real_user(params[:user][:name])
+ @message = "You cannot impersonate '#{params[:user][:username]}'."
+ @message = 'User name cannot be empty' if params[:user][:username].empty?
+ user = real_user(params[:user][:username])
check_if_user_impersonateable if user
- elsif !params[:impersonate][:name].empty?
+ elsif !params[:impersonate][:username].empty?
# Impersonate a new account
- @message = "You cannot impersonate '#{params[:impersonate][:name]}'."
- user = real_user(params[:impersonate][:name])
+ @message = "You cannot impersonate '#{params[:impersonate][:username]}'."
+ user = real_user(params[:impersonate][:username])
check_if_user_impersonateable if user
# Revert to original account when currently in the impersonated session
elsif !session[:super_user].nil?
@@ -143,11 +143,11 @@ def impersonate
# This method checks if the user is in anonymized view and accordingly returns the user object associated with the parameter
- def real_user(name)
+ def real_user(username)
if User.anonymized_view?(session[:ip])
- user = User.real_user_from_anonymized_name(name)
+ user = User.real_user_from_anonymized_username(username)
else
- user = User.find_by(name: name)
+ user = User.find_by(username: username)
end
return user
end
diff --git a/app/controllers/import_file_controller.rb b/app/controllers/import_file_controller.rb
index 0f70f5ca0a8..67e1a35af5e 100644
--- a/app/controllers/import_file_controller.rb
+++ b/app/controllers/import_file_controller.rb
@@ -53,10 +53,10 @@ def import
end
err_msg += ''
if errors.empty?
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'The file has been successfully imported.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'The file has been successfully imported.', request)
undo_link('The file has been successfully imported.')
else
- ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, err_msg, request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, err_msg, request)
flash[:error] = err_msg
end
redirect_to session[:return_to]
diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb
index 1bbc1db7f66..b64401b3525 100644
--- a/app/controllers/invitations_controller.rb
+++ b/app/controllers/invitations_controller.rb
@@ -19,7 +19,7 @@ def create
create_utility
else
ExpertizaLogger.error LoggerMessage.new('', @student.name, 'Student was already invited')
- flash[:note] = "You have already sent an invitation to \"#{@user.name}\"."
+ flash[:note] = "You have already sent an invitation to \"#{@user.username}\"."
end
update_join_team_request @user, @student
@@ -41,8 +41,8 @@ def update_join_team_request(user, student)
end
def auto_complete_for_user_name
- search = params[:user][:name].to_s
- @users = User.where('LOWER(name) LIKE ?', "%#{search}%") if search.present?
+ search = params[:user][:username].to_s
+ @users = User.where('LOWER(username) LIKE ?', "%#{search}%") if search.present?
end
def accept
@@ -86,7 +86,7 @@ def create_utility
def check_user_before_invitation
# user is the student you are inviting to your team
- @user = User.find_by(name: params[:user][:name].strip)
+ @user = User.find_by(username: params[:user][:username].strip)
# User/Author has information about the participant
@student = AssignmentParticipant.find(params[:student_id])
@assignment = Assignment.find(@student.parent_id)
@@ -96,7 +96,7 @@ def check_user_before_invitation
# check if the invited user is valid
unless @user
- flash[:error] = "The user \"#{params[:user][:name].strip}\" does not exist. Please make sure the name entered is correct."
+ flash[:error] = "The user \"#{params[:user][:username].strip}\" does not exist. Please make sure the username entered is correct."
redirect_to view_student_teams_path student_id: @student.id
return
end
@@ -110,7 +110,7 @@ def check_participant_before_invitation
if @assignment.is_conference_assignment
add_participant_coauthor
else
- flash[:error] = "The user \"#{params[:user][:name].strip}\" is not a participant in this assignment."
+ flash[:error] = "The user \"#{params[:user][:username].strip}\" is not a participant in this assignment."
redirect_to view_student_teams_path student_id: @student.id
return
end
@@ -134,7 +134,7 @@ def check_team_before_invitation
return if team_member.empty?
- flash[:error] = "The user \"#{@user.name}\" is already a member of the team."
+ flash[:error] = "The user \"#{@user.username}\" is already a member of the team."
redirect_to view_student_teams_path student_id: @student.id
end
diff --git a/app/controllers/lottery_controller.rb b/app/controllers/lottery_controller.rb
index 0deeceffbde..b239a594f81 100755
--- a/app/controllers/lottery_controller.rb
+++ b/app/controllers/lottery_controller.rb
@@ -22,14 +22,14 @@ def run_intelligent_assignment
users_bidding_info = construct_users_bidding_info(assignment.sign_up_topics, teams)
bidding_data = { users: users_bidding_info, max_team_size: assignment.max_team_size }
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Bidding data for assignment #{assignment.name}: #{bidding_data}", request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Bidding data for assignment #{assignment.name}: #{bidding_data}", request)
begin
url = WEBSERVICE_CONFIG['topic_bidding_webservice_url']
response = RestClient.post url, bidding_data.to_json, content_type: :json, accept: :json
# Structure of teams variable: [[user_id1, user_id2], [user_id3, user_id4]]
teams = JSON.parse(response)['teams']
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Team formation info for assignment #{assignment.name}: #{teams}", request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Team formation info for assignment #{assignment.name}: #{teams}", request)
create_new_teams_for_bidding_response(teams, assignment, users_bidding_info)
assignment.remove_empty_teams
match_new_teams_to_topics(assignment)
diff --git a/app/controllers/lti_controller.rb b/app/controllers/lti_controller.rb
index cd28c90add3..6741404904b 100644
--- a/app/controllers/lti_controller.rb
+++ b/app/controllers/lti_controller.rb
@@ -65,12 +65,12 @@ def valid_request_url?(url)
def authenticate_and_login_user(username)
begin
# Gets the user if they exist in Expertiza, else null
- user = User.find_by(name: username)
+ user = User.find_by(username: username)
if user
# Log the user in
session[:user] = user # Store the entire user object, not just the username
AuthController.set_current_role(user.role_id, session)
- ExpertizaLogger.info LoggerMessage.new('', user.name, 'Login successful via LTI')
+ ExpertizaLogger.info LoggerMessage.new('', user.username, 'Login successful via LTI')
redirect_to "#{ENV['EXPERTIZA_BASE_URL']}/student_task/list", notice: 'Logged in successfully via LTI'
else
redirect_to root_path, alert: 'User not found in Expertiza. Please register first.'
diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb
index a1bca28a7fd..5dd06c988b5 100644
--- a/app/controllers/participants_controller.rb
+++ b/app/controllers/participants_controller.rb
@@ -39,17 +39,17 @@ def add
#E2351 - add corresponding duty fill from permissions
can_mentor = permissions[:can_mentor]
if curr_object.is_a?(Assignment)
- curr_object.add_participant(params[:user][:name], can_submit, can_review, can_take_quiz, can_mentor)
+ curr_object.add_participant(params[:user][:username], can_submit, can_review, can_take_quiz, can_mentor)
elsif curr_object.is_a?(Course)
- curr_object.add_participant(params[:user][:name])
+ curr_object.add_participant(params[:user][:username])
end
- user = User.find_by(name: params[:user][:name])
+ user = User.find_by(username: params[:user][:username])
@model = params[:model]
@participant = curr_object.participants.find_by(user_id: user.id)
- flash.now[:note] = "The user #{params[:user][:name]} has successfully been added."
+ flash.now[:note] = "The user #{params[:user][:username]} has successfully been added."
rescue StandardError
url_for controller: 'users', action: 'new'
- flash.now[:error] = "The user #{params[:user][:name]} does not exist or has already been added."
+ flash.now[:error] = "The user #{params[:user][:username]} does not exist or has already been added."
end
render action: 'add.js.erb', layout: false
end
@@ -79,7 +79,7 @@ def destroy
parent_id = participant.parent_id
begin
participant.destroy
- flash[:note] = undo_link("The user \"#{participant.user.name}\" has been successfully removed as a participant.")
+ flash[:note] = undo_link("The user \"#{participant.user.username}\" has been successfully removed as a participant.")
rescue StandardError
flash[:error] = 'This participant is on a team, or is assigned as a reviewer for someone’s work.'
end
@@ -158,13 +158,13 @@ def change_handle
# Deletes participants from an assignment
def delete
contributor = AssignmentParticipant.find(params[:id])
- name = contributor.name
+ username = contributor.name
assignment_id = contributor.assignment
begin
contributor.destroy
- flash[:note] = "\"#{name}\" is no longer a participant in this assignment."
+ flash[:note] = "\"#{username}\" is no longer a participant in this assignment."
rescue StandardError
- flash[:error] = "\"#{name}\" was not removed from this assignment. Please ensure that \"#{name}\" is not a reviewer or metareviewer and try again."
+ flash[:error] = "\"#{username}\" was not removed from this assignment. Please ensure that \"#{username}\" is not a reviewer or metareviewer and try again."
end
redirect_to controller: 'review_mapping', action: 'list_mappings', id: assignment_id
end
@@ -204,7 +204,7 @@ def participant_params
# Get the user info from the team user
def get_user_info(team_user, assignment)
user = {}
- user[:name] = team_user.name
+ user[:username] = team_user.username
user[:fullname] = team_user.fullname
# set by default
permission_granted = false
diff --git a/app/controllers/password_retrieval_controller.rb b/app/controllers/password_retrieval_controller.rb
index 1f6856d29a0..af3c07e348f 100644
--- a/app/controllers/password_retrieval_controller.rb
+++ b/app/controllers/password_retrieval_controller.rb
@@ -18,7 +18,7 @@ def send_password
PasswordReset.save_token(user, token)
url = request.base_url + url_format + token
MailerHelper.send_mail_to_user(user, 'Expertiza password reset', 'send_password', url).deliver_now
- ExpertizaLogger.info LoggerMessage.new(controller_name, user.name, 'A link to reset your password has been sent to users e-mail address.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, user.username, 'A link to reset your password has been sent to users e-mail address.', request)
flash[:success] = 'A link to reset your password has been sent to your e-mail address.'
redirect_to '/'
else
@@ -71,10 +71,10 @@ def update_password
user.password_confirmation = params[:reset][:repassword]
if user.save
PasswordReset.where(user_email: user.email).delete_all
- ExpertizaLogger.info LoggerMessage.new(controller_name, user.name, 'Password was reset for the user', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, user.username, 'Password was reset for the user', request)
flash[:success] = 'Password was successfully reset'
else
- ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, 'Password reset operation failed for the user while saving record', request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, user.username, 'Password reset operation failed for the user while saving record', request)
flash[:error] = 'Password cannot be updated. Please try again'
end
redirect_to '/'
diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb
index c7053def3a4..4df0be244b0 100644
--- a/app/controllers/profile_controller.rb
+++ b/app/controllers/profile_controller.rb
@@ -18,12 +18,12 @@ def update
aq.update_attribute('notification_limit', params[:assignment_questionnaire][:notification_limit])
end
if @user.update_attributes(user_params)
- ExpertizaLogger.info LoggerMessage.new(controller_name, @user.name, 'Your profile was successfully updated.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, @user.username, 'Your profile was successfully updated.', request)
@user.etc_icons_on_homepage = params[:no_show_action] != 'not_show_actions'
@user.save!
flash[:success] = 'Your profile was successfully updated.'
else
- ExpertizaLogger.error LoggerMessage.new(controller_name, @user.name, 'An error occurred and your profile could not updated.', request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, @user.username, 'An error occurred and your profile could not updated.', request)
flash[:error] = 'An error occurred and your profile could not updated.'
end
diff --git a/app/controllers/response_controller.rb b/app/controllers/response_controller.rb
index 3d6829dfbd4..40550aecbbf 100644
--- a/app/controllers/response_controller.rb
+++ b/app/controllers/response_controller.rb
@@ -140,7 +140,7 @@ def update
rescue StandardError
msg = "Your response was not saved. Cause:189 #{$ERROR_INFO}"
end
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Your response was submitted: #{@response.is_submitted}", request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Your response was submitted: #{@response.is_submitted}", request)
redirect_to controller: 'response', action: 'save', id: @map.map_id,
return: params.permit(:return)[:return], msg: msg, review: params.permit(:review)[:review],
save_options: params.permit(:save_options)[:save_options]
@@ -254,7 +254,7 @@ def save
@map = ResponseMap.find(params[:id])
@return = params[:return]
@map.save
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Response was successfully saved')
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Response was successfully saved')
redirect_to action: 'redirect', id: @map.map_id, return: params.permit(:return)[:return], msg: params.permit(:msg)[:msg], error_msg: params.permit(:error_msg)[:error_msg]
end
diff --git a/app/controllers/review_mapping_controller.rb b/app/controllers/review_mapping_controller.rb
index 53c9c37cf2f..7de68007326 100755
--- a/app/controllers/review_mapping_controller.rb
+++ b/app/controllers/review_mapping_controller.rb
@@ -54,7 +54,7 @@ def select_metareviewer
def add_reviewer
assignment = Assignment.find(params[:id])
topic_id = params[:topic_id]
- user_id = User.where(name: params[:user][:name]).first.id
+ user_id = User.where(username: params[:user][:username]).first.id
# If instructor want to assign one student to review his/her own artifact,
# it should be counted as "self-review" and we need to make /app/views/submitted_content/_selfreview.html.erb work.
if TeamsUser.exists?(team_id: params[:contributor_id], user_id: user_id)
@@ -198,7 +198,7 @@ def add_metareviewer
regurl = url_for action: 'add_user_to_assignment', id: mapping.map_id, user_id: user.id
reviewer = get_reviewer(user, mapping.assignment, regurl)
unless MetareviewResponseMap.where(reviewed_object_id: mapping.map_id, reviewer_id: reviewer.id).first.nil?
- raise 'The metareviewer "' + reviewer.user.name + '" is already assigned to this reviewer.'
+ raise 'The metareviewer "' + reviewer.user.username + '" is already assigned to this reviewer.'
end
MetareviewResponseMap.create(reviewed_object_id: mapping.map_id,
@@ -224,7 +224,7 @@ def assign_metareviewer_dynamically
def get_reviewer(user, assignment, reg_url)
reviewer = AssignmentParticipant.where(user_id: user.id, parent_id: assignment.id).first
- raise "\"#{user.name}\" is not a participant in the assignment. Please register this user to continue." if reviewer.nil?
+ raise "\"#{user.username}\" is not a participant in the assignment. Please register this user to continue." if reviewer.nil?
reviewer.get_reviewer
rescue StandardError => e
diff --git a/app/controllers/sign_up_sheet_controller.rb b/app/controllers/sign_up_sheet_controller.rb
index 73a6de1ce5d..bc6b7d91276 100755
--- a/app/controllers/sign_up_sheet_controller.rb
+++ b/app/controllers/sign_up_sheet_controller.rb
@@ -243,7 +243,7 @@ def sign_up
def signup_as_instructor; end
def signup_as_instructor_action
- user = User.find_by(name: params[:username])
+ user = User.find_by(username: params[:username])
if user.nil? # validate invalid user
flash[:error] = 'That student does not exist!'
else
@@ -414,7 +414,7 @@ def show_team
@results.each do |result|
@team_members = ''
TeamsUser.where(team_id: result[:team_id]).each do |teamuser|
- @team_members += User.find(teamuser.user_id).name + ' '
+ @team_members += User.find(teamuser.user_id).username + ' '
end
end
# @team_members = find_team_members(topic)
diff --git a/app/controllers/student_teams_controller.rb b/app/controllers/student_teams_controller.rb
index 4ce770c5b03..d1b274e91a3 100644
--- a/app/controllers/student_teams_controller.rb
+++ b/app/controllers/student_teams_controller.rb
@@ -72,7 +72,7 @@ def create
if existing_teams.empty?
if params[:team][:name].blank?
flash[:notice] = 'The team name is empty.'
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Team name missing while creating team', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Team name missing while creating team', request)
redirect_to view_student_teams_path student_id: student.id
return
end
@@ -93,7 +93,7 @@ def create
else
flash[:notice] = 'That team name is already in use.'
- ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'Team name being created was already in use', request)
+ ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'Team name being created was already in use', request)
redirect_to view_student_teams_path student_id: student.id
end
end
@@ -113,7 +113,7 @@ def update
redirect_to view_student_teams_path student_id: params[:student_id]
else
flash[:notice] = 'That team name is already in use.'
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Team name being updated to was already in use', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Team name being updated to was already in use', request)
redirect_to view_student_teams_path student_id: params[:student_id]
end
@@ -145,7 +145,7 @@ def remove_team_user(team_user)
team_user.destroy_all
undo_link "The user \"#{team_user.name}\" has been successfully removed from the team."
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'User removed a participant from the team', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'User removed a participant from the team', request)
end
def team_created_successfully(current_team = nil)
@@ -154,7 +154,7 @@ def team_created_successfully(current_team = nil)
else
undo_link "The team \"#{team.name}\" has been successfully updated."
end
- ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'The team has been successfully created.', request)
+ ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'The team has been successfully created.', request)
end
# This method is used to show the Author Feedback Questionnaire of current assignment
diff --git a/app/controllers/submitted_content_controller.rb b/app/controllers/submitted_content_controller.rb
index b11252b808b..ebf8debbd15 100644
--- a/app/controllers/submitted_content_controller.rb
+++ b/app/controllers/submitted_content_controller.rb
@@ -258,7 +258,7 @@ def delete_selected_files
team = participant.try(:team)
SubmissionRecord.create(team_id: team.try(:id),
content: filename,
- user: participant.try(:name),
+ user: participant.try(:username),
assignment_id: assignment.try(:id),
operation: 'Remove File')
ExpertizaLogger.info LoggerMessage.new(controller_name, @participant.name, 'The selected file has been deleted.', request)
diff --git a/app/controllers/suggestion_controller.rb b/app/controllers/suggestion_controller.rb
index e4954e11e59..24c15470543 100644
--- a/app/controllers/suggestion_controller.rb
+++ b/app/controllers/suggestion_controller.rb
@@ -13,7 +13,7 @@ def action_allowed?
def add_comment
@suggestion_comment = SuggestionComment.new(vote: params[:suggestion_comment][:vote], comments: params[:suggestion_comment][:comments])
@suggestion_comment.suggestion_id = params[:id]
- @suggestion_comment.commenter = session[:user].name
+ @suggestion_comment.commenter = session[:user].username
if @suggestion_comment.save
flash[:notice] = 'Your comment has been successfully added.'
else
@@ -57,7 +57,7 @@ def update_suggestion
def new
@suggestion = Suggestion.new
session[:assignment_id] = params[:id]
- @suggestions = Suggestion.where(unityID: session[:user].name, assignment_id: params[:id])
+ @suggestions = Suggestion.where(unityID: session[:user].username, assignment_id: params[:id])
@assignment = Assignment.find(params[:id])
end
@@ -67,7 +67,7 @@ def create
@assignment = Assignment.find(session[:assignment_id])
@suggestion.status = 'Initiated'
@suggestion.unityID = if params[:suggestion_anonymous].nil?
- session[:user].name
+ session[:user].username
else
''
end
@@ -105,7 +105,7 @@ def send_email
subject: "Suggested topic '#{@suggestion.title}' has been approved",
body: {
approved_topic_name: @suggestion.title,
- proposer: proposer.name
+ proposer: proposer.username
}
).deliver_now!
end
@@ -160,7 +160,7 @@ def suggestion_params
def approve
@suggestion = Suggestion.find(params[:id])
- @user_id = User.find_by(name: @suggestion.unityID).try(:id)
+ @user_id = User.find_by(username: @suggestion.unityID).try(:id)
if @user_id
@team_id = TeamsUser.team_id(@suggestion.assignment_id, @user_id)
@topic_id = SignedUpTeam.topic_id(@suggestion.assignment_id, @user_id)
diff --git a/app/controllers/teams_users_controller.rb b/app/controllers/teams_users_controller.rb
index b0b71610617..99fd992335c 100644
--- a/app/controllers/teams_users_controller.rb
+++ b/app/controllers/teams_users_controller.rb
@@ -12,8 +12,8 @@ def action_allowed?
def auto_complete_for_user_name
team = Team.find(session[:team_id])
- @users = team.get_possible_team_members(params[:user][:name])
- render inline: "<%= auto_complete_result @users, 'name' %>", layout: false
+ @users = team.get_possible_team_members(params[:user][:username])
+ render inline: "<%= auto_complete_result @users, 'username' %>", layout: false
end
# Example of duties: manager, designer, programmer, tester. Finds TeamsUser and save preferred Duty
@@ -34,10 +34,10 @@ def new
end
def create
- user = User.find_by(name: params[:user][:name].strip)
+ user = User.find_by(username: params[:user][:username].strip)
unless user
urlCreate = url_for controller: 'users', action: 'new'
- flash[:error] = "\"#{params[:user][:name].strip}\" is not defined. Please create this user before continuing."
+ flash[:error] = "\"#{params[:user][:username].strip}\" is not defined. Please create this user before continuing."
end
team = Team.find(params[:id])
@@ -51,12 +51,12 @@ def create
end
if AssignmentParticipant.find_by(user_id: user.id, parent_id: assignment.id).nil?
urlAssignmentParticipantList = url_for controller: 'participants', action: 'list', id: assignment.id, model: 'Assignment', authorization: 'participant'
- flash[:error] = "\"#{user.name}\" is not a participant of the current assignment. Please add this user before continuing."
+ flash[:error] = "\"#{user.username}\" is not a participant of the current assignment. Please add this user before continuing."
else
begin
add_member_return = team.add_member(user, team.parent_id)
rescue
- flash[:error] = "The user #{user.name} is already a member of the team #{team.name}"
+ flash[:error] = "The user #{user.username} is already a member of the team #{team.name}"
redirect_back fallback_location: root_path
return
end
@@ -71,19 +71,19 @@ def create
end
if CourseParticipant.find_by(user_id: user.id, parent_id: course.id).nil?
urlCourseParticipantList = url_for controller: 'participants', action: 'list', id: course.id, model: 'Course', authorization: 'participant'
- flash[:error] = "\"#{user.name}\" is not a participant of the current course. Please add this user before continuing."
+ flash[:error] = "\"#{user.username}\" is not a participant of the current course. Please add this user before continuing."
else
begin
add_member_return = team.add_member(user, team.parent_id)
rescue
- flash[:error] = "The user #{user.name} is already a member of the team #{team.name}"
+ flash[:error] = "The user #{user.username} is already a member of the team #{team.name}"
redirect_back fallback_location: root_path
return
end
flash[:error] = 'This team already has the maximum number of members.' if add_member_return == false
if add_member_return
@teams_user = TeamsUser.last
- undo_link("The team user \"#{user.name}\" has been successfully added to \"#{team.name}\".")
+ undo_link("The team user \"#{user.username}\" has been successfully added to \"#{team.name}\".")
end
end
end
@@ -97,7 +97,7 @@ def delete
parent_id = Team.find(@teams_user.team_id).parent_id
@user = User.find(@teams_user.user_id)
@teams_user.destroy
- undo_link("The team user \"#{@user.name}\" has been successfully removed. ")
+ undo_link("The team user \"#{@user.username}\" has been successfully removed. ")
redirect_to controller: 'teams', action: 'list', id: parent_id
end
diff --git a/app/controllers/tree_display_controller.rb b/app/controllers/tree_display_controller.rb
index e846927fd7d..d8fa3f56448 100644
--- a/app/controllers/tree_display_controller.rb
+++ b/app/controllers/tree_display_controller.rb
@@ -317,7 +317,7 @@ def serialize_folder_to_json(folder_type, node)
'private' => course_is_available?(node)
)
json['instructor_id'] = node.get_instructor_id
- json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).name(session[:ip]) : nil
+ json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).username(session[:ip]) : nil
json['is_available'] = course_is_available?(node)
serialize_assignment_to_json(node, json) if folder_type == 'Assignments'
end
@@ -339,7 +339,7 @@ def serialize_sub_folder_to_json(node)
if (node.type == 'CourseNode') || (node.type == 'AssignmentNode')
json['directory'] = node.get_directory
json['instructor_id'] = node.get_instructor_id
- json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).name(session[:ip]) : nil
+ json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).username(session[:ip]) : nil
json['is_available'] = course_is_available?(node)
serialize_assignment_to_json(node, json) if node.type == 'AssignmentNode'
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 0d93bccce43..791ec4f6282 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -42,8 +42,8 @@ def index
def auto_complete_for_user_name
user = session[:user]
role = Role.find(user.role_id)
- @users = User.where('name LIKE ? and (role_id in (?) or id = ?)', "#{params[:user][:name]}%", role.get_available_roles, user.id)
- render inline: "<%= auto_complete_result @users, 'name' %>", layout: false
+ @users = User.where('username LIKE ? and (role_id in (?) or id = ?)', "#{params[:user][:username]}%", role.get_available_roles, user.id)
+ render inline: "<%= auto_complete_result @users, 'username' %>", layout: false
end
# for anonymized view for demo purposes
@@ -67,7 +67,7 @@ def list
if letter.present? && search_by.present?
case search_by.to_i
when 1 # Search by username
- @paginated_users = paginate_list.where('name LIKE ?', "%#{letter}%")
+ @paginated_users = paginate_list.where('username LIKE ?', "%#{letter}%")
when 2 # Search by fullname
@paginated_users = paginate_list.where('fullname LIKE ?', "%#{letter}%")
when 3 # Search by email
@@ -82,9 +82,9 @@ def list
# for displaying users which are being searched for editing purposes after checking whether current user is authorized to do so
def show_if_authorized
- @user = User.find_by(name: params[:user][:name])
+ @user = User.find_by(username: params[:user][:username])
if @user.nil?
- flash[:note] = params[:user][:name] + ' does not exist.'
+ flash[:note] = params[:user][:username] + ' does not exist.'
redirect_to action: 'list'
else
role
@@ -121,9 +121,9 @@ def new
def create
# if the user name already exists, register the user by email address
- check = User.find_by(name: params[:user][:name])
+ check = User.find_by(username: params[:user][:username])
if check
- params[:user][:name] = params[:user][:email]
+ params[:user][:username] = params[:user][:email]
flash[:note] = "That username already exists. Username has been set to the user's email address"
end
is_user = true
@@ -140,7 +140,7 @@ def create
# TAs and Students do not need a default. TAs inherit the default from the instructor,
# Students do not have any checks for this information.
AssignmentQuestionnaire.create(user_id: @user.id) if (@user.role.name == 'Instructor') || (@user.role.name == 'Administrator')
- undo_link("The user \"#{@user.name}\" has been successfully created. ")
+ undo_link("The user \"#{@user.username}\" has been successfully created. ")
redirect_to action: 'list'
else
foreign
@@ -165,10 +165,10 @@ def update
# update username, when the user cannot be deleted
# rename occurs in 'show' page, not in 'edit' page
# eg. /users/5408?name=5408
- @user.name += '_hidden' if request.original_fullpath == "/users/#{@user.id}?name=#{@user.id}"
+ @user.username += '_hidden' if request.original_fullpath == "/users/#{@user.id}?username=#{@user.id}"
if @user.update_attributes(params[:user])
- flash[:success] = "The user \"#{@user.name}\" has been successfully updated."
+ flash[:success] = "The user \"#{@user.username}\" has been successfully updated."
redirect_to @user
else
render action: 'edit'
@@ -183,7 +183,7 @@ def destroy
AssignmentQuestionnaire.where(user_id: @user.id).each(&:destroy)
# Participant.delete(true)
@user.destroy
- flash[:note] = "The user \"#{@user.name}\" has been successfully deleted."
+ flash[:note] = "The user \"#{@user.username}\" has been successfully deleted."
rescue StandardError
flash[:error] = $ERROR_INFO
end
@@ -214,7 +214,7 @@ def foreign
# add user etc_icons_on_homepage
def user_params
- params.require(:user).permit(:name,
+ params.require(:user).permit(:username,
:crypted_password,
:role_id,
:password_salt,
diff --git a/app/helpers/answer_helper.rb b/app/helpers/answer_helper.rb
index 2a89ddc53bd..6c68a5c4a76 100644
--- a/app/helpers/answer_helper.rb
+++ b/app/helpers/answer_helper.rb
@@ -42,7 +42,7 @@ def self.log_response_info(response_ids)
user = Participant.find(reviewer_id).user
answers_per_user = Answer.find_by(response_id: response_id).comments
# For each response_id, add its info to the dictionary
- user_id_to_answers[response_id] = { email: user.email, answers: answers_per_user, name: user.name, assignment_name: assignment_name } unless user.nil?
+ user_id_to_answers[response_id] = { email: user.email, answers: answers_per_user, username: user.username, assignment_name: assignment_name } unless user.nil?
end
user_id_to_answers
end
diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb
index 049d245e320..3c422cc27fc 100644
--- a/app/helpers/conference_helper.rb
+++ b/app/helpers/conference_helper.rb
@@ -36,7 +36,7 @@ def get_redirect_url_link
end
def create_author
- params[:user][:name] = params[:user][:email] unless !params[:user][:name].nil? && !params[:user][:name].empty?
+ params[:user][:username] = params[:user][:email] unless !params[:user][:username].nil? && !params[:user][:username].empty?
is_author = true
# Assign all user params for creating author using assign_user_params function
@user = assign_user_params(is_author)
@@ -53,7 +53,7 @@ def create_author
end
def create_coauthor
- check = User.find_by(name: params[:user][:name])
+ check = User.find_by(username: params[:user][:name])
params[:user][:name] = params[:user][:email] unless check.nil?
User.skip_callback(:create, :after, :email_welcome)
is_author = false
@@ -66,7 +66,7 @@ def create_coauthor
# password is regenerated so that we could provide it in a mail
password = @user.reset_password
# Mail to be sent to co-author once the user has been created. New partial is used as content for email is different from normal user
- MailerHelper.send_mail_for_conference_user(@user, 'Your Expertiza account has been created.', 'user_conference_invitation', password, current_user.name).deliver
+ MailerHelper.send_mail_for_conference_user(@user, 'Your Expertiza account has been created.', 'user_conference_invitation', password, current_user.username).deliver
@user
end
end
@@ -90,7 +90,7 @@ def assign_user_params(is_author)
@user = User.new(user_params)
# Checks if its a co-author
if !is_author
- @user.email = params[:user][:name]
+ @user.email = params[:user][:username]
# parent_id denotes who created the co-author
@user.parent_id = session[:user].id
# co-author role is same as student hence role_id =1
@@ -119,7 +119,7 @@ def assign_user_params(is_author)
end
def user_params
- params.require(:user).permit(:name,
+ params.require(:user).permit(:username,
:fullname,
:role_id,
:email,
diff --git a/app/helpers/import_file_helper.rb b/app/helpers/import_file_helper.rb
index c0b59049291..5991ff1abe4 100644
--- a/app/helpers/import_file_helper.rb
+++ b/app/helpers/import_file_helper.rb
@@ -4,7 +4,7 @@ module ImportFileHelper
def self.define_attributes(row_hash)
attributes = {}
attributes['role_id'] = Role.student.id
- attributes['name'] = row_hash[:username]
+ attributes['username'] = row_hash[:username]
attributes['fullname'] = row_hash[:fullname]
attributes['email'] = row_hash[:email]
attributes['email_on_submission'] = 1
diff --git a/app/helpers/manage_team_helper.rb b/app/helpers/manage_team_helper.rb
index e0ce5c093f6..5e84ca8906d 100644
--- a/app/helpers/manage_team_helper.rb
+++ b/app/helpers/manage_team_helper.rb
@@ -8,7 +8,7 @@ def create_team_users(user, team_id)
unless user
urlCreate = url_for controller: 'users', action: 'new'
ExpertizaLogger.error LoggerMessage.new('ManageTeamHelper', '', 'User being added to the team does not exist!', request)
- flash[:error] = "\"#{params[:user][:name].strip}\" is not defined. Please create this user before continuing."
+ flash[:error] = "\"#{params[:user][:username].strip}\" is not defined. Please create this user before continuing."
end
# find the team with 'team_id' form database and add new user to team
team = Team.find(team_id)
diff --git a/app/helpers/participants_helper.rb b/app/helpers/participants_helper.rb
index 08494c55737..0b936095666 100644
--- a/app/helpers/participants_helper.rb
+++ b/app/helpers/participants_helper.rb
@@ -15,7 +15,7 @@ def self.upload_users(filename, session, params, home_page)
def self.define_attributes(line_split, config)
attributes = {}
attributes['role_id'] = Role.find_by name: 'Student'
- attributes['name'] = line_split[config['name'].to_i]
+ attributes['username'] = line_split[config['username'].to_i]
attributes['fullname'] = config['fullname']
attributes['email'] = line_split[config['email'].to_i]
attributes['password'] = (0...8).map { (65 + rand(26)).chr }.join
@@ -26,7 +26,7 @@ def self.define_attributes(line_split, config)
end
def self.define_user(attrs, session, params, home_page)
- user = User.find_by(name: attrs['name'])
+ user = User.find_by(username: attrs['username'])
user = create_new_user(attrs, session) if user.nil?
if !params[:course_id].nil?
participant = add_user_to_course(params, user)
@@ -64,7 +64,7 @@ def self.get_config
File.open(cfgdir + 'roster_config', 'r') do |infile|
while (line = infile.gets)
store_item(line, 'dlm', config)
- store_item(line, 'name', config)
+ store_item(line, 'username', config)
store_item(line, 'fullname', config)
store_item(line, 'email', config)
end
diff --git a/app/helpers/report_formatter_helper.rb b/app/helpers/report_formatter_helper.rb
index bbfd6abcde7..6cae86ca869 100644
--- a/app/helpers/report_formatter_helper.rb
+++ b/app/helpers/report_formatter_helper.rb
@@ -91,21 +91,21 @@ def create_participant(parent_id, user_id)
end
def user_summary_report(line)
- if @user_tagging_report[line.user.name].nil?
+ if @user_tagging_report[line.user.username].nil?
# E2082 Adding extra field of interval array into data structure
- @user_tagging_report[line.user.name] = VmUserAnswerTagging.new(line.user, line.percentage, line.no_tagged, line.no_not_tagged, line.no_tagable, line.tag_update_intervals)
+ @user_tagging_report[line.user.username] = VmUserAnswerTagging.new(line.user, line.percentage, line.no_tagged, line.no_not_tagged, line.no_tagable, line.tag_update_intervals)
else
- @user_tagging_report[line.user.name].no_tagged += line.no_tagged
- @user_tagging_report[line.user.name].no_not_tagged += line.no_not_tagged
- @user_tagging_report[line.user.name].no_tagable += line.no_tagable
- @user_tagging_report[line.user.name].percentage = calculate_formatted_percentage(line)
+ @user_tagging_report[line.user.username].no_tagged += line.no_tagged
+ @user_tagging_report[line.user.username].no_not_tagged += line.no_not_tagged
+ @user_tagging_report[line.user.username].no_tagable += line.no_tagable
+ @user_tagging_report[line.user.username].percentage = calculate_formatted_percentage(line)
end
end
def calculate_formatted_percentage(line)
- number_tagged = @user_tagging_report[line.user.name].no_tagged.to_f
- number_taggable = @user_tagging_report[line.user.name].no_tagable
+ number_tagged = @user_tagging_report[line.user.username].no_tagged.to_f
+ number_taggable = @user_tagging_report[line.user.username].no_tagable
formatted_percentage = format('%.1f', (number_tagged / number_taggable) * 100)
- @user_tagging_report[line.user.name].no_tagable.zero? ? '-' : formatted_percentage
+ @user_tagging_report[line.user.username].no_tagable.zero? ? '-' : formatted_percentage
end
end
diff --git a/app/models/account_request.rb b/app/models/account_request.rb
index 85e5a3a18dd..bd9ac143843 100644
--- a/app/models/account_request.rb
+++ b/app/models/account_request.rb
@@ -1,7 +1,7 @@
class AccountRequest < ApplicationRecord
before_save { self.email = email.downcase }
- before_save { name }
- validates :name, presence: true, length: { maximum: 50, message: 'is too long' }
+ before_save { username }
+ validates :username, presence: true, length: { maximum: 50, message: 'is too long' }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i.freeze
validates :email, presence: true, length: { maximum: 255, message: 'is too long' },
format: { with: VALID_EMAIL_REGEX, message: 'format is wrong' },
diff --git a/app/models/assignment.rb b/app/models/assignment.rb
index 8f9bed41aab..1b99425997c 100755
--- a/app/models/assignment.rb
+++ b/app/models/assignment.rb
@@ -177,10 +177,10 @@ def path
end
path_text = if !course_id.nil? && course_id > 0
- Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:name]) + '/' +
+ Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:username]) + '/' +
FileHelper.clean_path(course.directory_path) + '/'
else
- Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:name]) + '/'
+ Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:username]) + '/'
end
path_text += FileHelper.clean_path(directory_path)
path_text
@@ -270,13 +270,13 @@ def badge?
# manual addition
# user_name - the user account name of the participant to add
def add_participant(user_name, can_submit, can_review, can_take_quiz, can_mentor)
- user = User.find_by(name: user_name)
+ user = User.find_by(username: user_name)
if user.nil?
- raise "The user account with the name #{user_name} does not exist. Please create the user first."
end
participant = AssignmentParticipant.find_by(parent_id: id, user_id: user.id)
- raise "The user #{user.name} is already a participant." if participant
+ raise "The user #{user.username} is already a participant." if participant
new_part = AssignmentParticipant.create(parent_id: id,
user_id: user.id,
@@ -444,7 +444,7 @@ def self.csv_row(detail_options, answer)
reviewer = Participant.find(map.reviewer_id).user
teams_csv << handle_nil(@reviewee.id) if detail_options['team_id'] == 'true'
teams_csv << handle_nil(@reviewee.name) if detail_options['team_name'] == 'true'
- teams_csv << handle_nil(reviewer.name) if detail_options['reviewer'] == 'true'
+ teams_csv << handle_nil(reviewer.username) if detail_options['reviewer'] == 'true'
teams_csv << handle_nil(answer.question.txt) if detail_options['question'] == 'true'
teams_csv << handle_nil(answer.question.id) if detail_options['question_id'] == 'true'
teams_csv << handle_nil(answer.id) if detail_options['comment_id'] == 'true'
@@ -483,7 +483,7 @@ def self.export_headers(parent_id)
@assignment = Assignment.find(parent_id)
fields = []
fields << 'Assignment Name: ' + @assignment.name.to_s
- fields << 'Assignment Instructor: ' + User.find(@assignment.instructor_id).name.to_s
+ fields << 'Assignment Instructor: ' + User.find(@assignment.instructor_id).username.to_s
fields
end
diff --git a/app/models/assignment_participant.rb b/app/models/assignment_participant.rb
index f38245fb062..5a2605ea097 100644
--- a/app/models/assignment_participant.rb
+++ b/app/models/assignment_participant.rb
@@ -113,7 +113,7 @@ def team
def self.import(row_hash, _row_header = nil, session, id)
raise ArgumentError, 'No user id has been specified.' if row_hash.empty?
- user = User.find_by(name: row_hash[:username])
+ user = User.find_by(username: row_hash[:username])
# if user with provided name in csv file is not present then new user will be created.
if user.nil?
@@ -154,9 +154,9 @@ def verify_digital_signature(private_key)
# define a handle for a new participant
def set_handle
self.handle = if user.handle.nil? || (user.handle == '')
- user.name
+ user.username
elsif AssignmentParticipant.exists?(parent_id: assignment.id, handle: user.handle)
- user.name
+ user.username
else
user.handle
end
diff --git a/app/models/course.rb b/app/models/course.rb
index 7ec1c39e452..c6454d8971a 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -23,7 +23,7 @@ def get_teams
def path
raise 'Path can not be created. The course must be associated with an instructor.' if instructor_id.nil?
- Rails.root + '/pg_data/' + FileHelper.clean_path(User.find(instructor_id).name) + '/' + FileHelper.clean_path(directory_path) + '/'
+ Rails.root + '/pg_data/' + FileHelper.clean_path(User.find(instructor_id).username) + '/' + FileHelper.clean_path(directory_path) + '/'
end
def get_participants
@@ -35,14 +35,14 @@ def get_participant(user_id)
end
def add_participant(user_name)
- user = User.find_by(name: user_name)
+ user = User.find_by(username: user_name)
if user.nil?
raise 'No user account exists with the name ' + user_name + ". Please create the user first."
end
participant = CourseParticipant.where(parent_id: id, user_id: user.id).first
if participant # If there is already a participant, raise an error. Otherwise, create it
- raise "The user #{user.name} is already a participant."
+ raise "The user #{user.username} is already a participant."
else
CourseParticipant.create(parent_id: id, user_id: user.id, permission_granted: user.master_permission_granted)
end
@@ -56,7 +56,7 @@ def copy_participants(assignment_id)
user = User.find(participant.user_id)
begin
- add_participant(user.name)
+ add_participant(user.username)
rescue StandardError
errors << $ERROR_INFO
end
diff --git a/app/models/course_participant.rb b/app/models/course_participant.rb
index cc79aa778e0..31fc11c17b6 100644
--- a/app/models/course_participant.rb
+++ b/app/models/course_participant.rb
@@ -15,7 +15,7 @@ def copy(assignment_id)
def self.import(row_hash, _row_header = nil, session, id)
raise ArgumentError, 'No user id has been specified.' if row_hash.empty?
- user = User.find_by(name: row_hash[:username])
+ user = User.find_by(username: row_hash[:username])
if user.nil?
raise ArgumentError, "The record containing #{row_hash[:username]} does not have enough items." if row_hash.length < 4
diff --git a/app/models/course_team.rb b/app/models/course_team.rb
index 14e58c6c39d..7bac5d7245e 100644
--- a/app/models/course_team.rb
+++ b/app/models/course_team.rb
@@ -68,7 +68,7 @@ def self.export_fields(options)
# Add member to the course team
def add_member(user, _id = nil)
- raise "The user \"#{user.name}\" 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)
t_user = TeamsUser.create(user_id: user.id, team_id: id)
parent = TeamNode.find_by(node_object_id: id)
diff --git a/app/models/mentor_management.rb b/app/models/mentor_management.rb
index 54a71096463..0adfdf5a468 100644
--- a/app/models/mentor_management.rb
+++ b/app/models/mentor_management.rb
@@ -3,7 +3,7 @@ class MentorManagement
#
# 1) Find all assignment participants for the
# assignment with id [assignment_id] whose
- # duty is the same as [Particpant#DUTY_MENTOR].
+ # duty is the same as [Participant#DUTY_MENTOR].
# 2) Count the number of teams those participants
# are a part of, acting as a proxy for the
# number of teams they mentor.
diff --git a/app/models/mentored_team.rb b/app/models/mentored_team.rb
index daccd65d37d..6363b53dce6 100644
--- a/app/models/mentored_team.rb
+++ b/app/models/mentored_team.rb
@@ -2,7 +2,7 @@ class MentoredTeam < AssignmentTeam
# Class created during refactoring of E2351
# Overridden method to include the MentorManagement workflow
def add_member(user, _assignment_id = nil)
- raise "The user #{user.name} 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?
@@ -11,7 +11,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', user.name, "Added member to the team #{id}")
+ ExpertizaLogger.info LoggerMessage.new('Model:Team', user.username, "Added member to the team #{id}")
end
if can_add_member
MentorManagement.assign_mentor(_assignment_id, id)
diff --git a/app/models/metareview_response_map.rb b/app/models/metareview_response_map.rb
index fdfb87e8dde..88f98f0e275 100644
--- a/app/models/metareview_response_map.rb
+++ b/app/models/metareview_response_map.rb
@@ -64,11 +64,11 @@ def self.import(row_hash, _session, id)
contributor = AssignmentTeam.where(name: row_hash[:reviewee].to_s, parent_id: id).first
raise ImportError, 'Contributor, ' + row_hash[:reviewee].to_s + ', was not found.' if contributor.nil?
- ruser = User.find_by_name(row_hash[:reviewer].to_s.strip)
+ ruser = User.find_by_username(row_hash[:reviewer].to_s.strip)
reviewee = AssignmentParticipant.where(user_id: ruser.id, parent_id: id).first
raise ImportError, "Reviewee, #{row_hash[:reviewer]}, for contributor, #{contributor.name}, was not found." if reviewee.nil?
- muser = User.find_by_name(row.to_s.strip)
+ muser = User.find_by_username(row.to_s.strip)
reviewer = AssignmentParticipant.where(user_id: muser.id, parent_id: id)
raise ImportError, "Metareviewer, #{row}, for contributor, #{contributor.name}, and reviewee, #{row_hash[:reviewer]}, was not found." if reviewer.nil?
diff --git a/app/models/participant.rb b/app/models/participant.rb
index cd282e096b7..1af7b893512 100644
--- a/app/models/participant.rb
+++ b/app/models/participant.rb
@@ -36,7 +36,7 @@ def responses
end
def name(ip_address = nil)
- user.name(ip_address)
+ user.username(ip_address)
end
def fullname(ip_address = nil)
@@ -102,7 +102,7 @@ def email(pw, home_page)
body: {
home_page: home_page,
first_name: ApplicationHelper.get_user_first_name(user),
- name: user.name,
+ name: user.username,
password: pw,
partial_name: 'register'
}
@@ -127,7 +127,7 @@ def authorization
def self.sort_by_name(participants)
users = []
participants.each { |p| users << p.user }
- users.sort! { |a, b| a.name.downcase <=> b.name.downcase } # Sort the users based on the name
+ users.sort! { |a, b| a.username.downcase <=> b.username.downcase } # Sort the users based on the name
participants.sort_by { |p| users.map(&:id).index(p.user_id) }
end
@@ -136,9 +136,9 @@ def self.export(csv, parent_id, options)
where(parent_id: parent_id).find_each do |part|
tcsv = []
user = part.user
- tcsv.push(user.name, user.fullname, user.email) if options['personal_details'] == 'true'
+ tcsv.push(user.username, user.fullname, user.email) if options['personal_details'] == 'true'
tcsv.push(user.role.name) if options['role'] == 'true'
- tcsv.push(user.parent.name) if options['parent'] == 'true'
+ tcsv.push(user.parent.username) if options['parent'] == 'true'
tcsv.push(user.email_on_submission, user.email_on_review, user.email_on_review_of_review) if options['email_options'] == 'true'
tcsv.push(part.handle) if options['handle'] == 'true'
csv << tcsv
diff --git a/app/models/review_response_map.rb b/app/models/review_response_map.rb
index 0ea43d9a0a7..b42e17ae9ad 100644
--- a/app/models/review_response_map.rb
+++ b/app/models/review_response_map.rb
@@ -45,7 +45,7 @@ def self.export(csv, parent_id, _options)
def self.import(row_hash, _session, assignment_id)
reviewee_user_name = row_hash[:reviewee].to_s
- reviewee_user = User.find_by(name: reviewee_user_name)
+ reviewee_user = User.find_by(username: reviewee_user_name)
raise ArgumentError, 'Cannot find reviewee user.' unless reviewee_user
reviewee_participant = AssignmentParticipant.find_by(user_id: reviewee_user.id, parent_id: assignment_id)
@@ -61,7 +61,7 @@ def self.import(row_hash, _session, assignment_id)
end
row_hash[:reviewers].each do |reviewer|
reviewer_user_name = reviewer.to_s
- reviewer_user = User.find_by(name: reviewer_user_name)
+ reviewer_user = User.find_by(username: reviewer_user_name)
raise ArgumentError, 'Cannot find reviewer user.' unless reviewer_user
next if reviewer_user_name.empty?
diff --git a/app/models/sign_up_sheet.rb b/app/models/sign_up_sheet.rb
index b245d7e0235..b6bf871fa23 100755
--- a/app/models/sign_up_sheet.rb
+++ b/app/models/sign_up_sheet.rb
@@ -89,7 +89,7 @@ def self.import(row_hash, session, _id = nil)
while row_hash.length > params
index = 'user_name_' + params.to_s
- user = User.find_by(name: row_hash[index.to_sym].to_s)
+ user = User.find_by(username: row_hash[index.to_sym].to_s)
raise ImportError, 'The user, ' + row_hash[index.to_sym].to_s.strip + ', was not found.' if user.nil?
participant = AssignmentParticipant.where(parent_id: session[:assignment_id], user_id: user.id).first
diff --git a/app/models/signed_up_team.rb b/app/models/signed_up_team.rb
index 2a4564322b7..d59d05e2393 100755
--- a/app/models/signed_up_team.rb
+++ b/app/models/signed_up_team.rb
@@ -15,7 +15,7 @@ def self.find_team_participants(assignment_id, ip_address = nil)
@participants.each_with_index do |participant, i|
participant_names = User.joins('INNER JOIN teams_users ON users.id = teams_users.user_id')
.joins('INNER JOIN teams ON teams.id = teams_users.team_id')
- .select('users.name as u_name, teams.name as team_name')
+ .select('users.username as u_name, teams.name as team_name')
.where('teams.id = ?', participant.team_id)
team_name_added = false
@@ -23,12 +23,12 @@ def self.find_team_participants(assignment_id, ip_address = nil)
participant_names.each do |participant_name|
if team_name_added
- names += User.find_by(name: participant_name.u_name).name(ip_address) + ' '
- participant.user_name_placeholder += User.find_by(name: participant_name.u_name).name(ip_address) + ' '
+ names += User.find_by(username: participant_name.u_name).name(ip_address) + ' '
+ participant.user_name_placeholder += User.find_by(username: participant_name.u_name).name(ip_address) + ' '
else
- names = '[' + participant_name.team_name + '] ' + User.find_by(name: participant_name.u_name).name(ip_address) + ' '
+ names = '[' + participant_name.team_name + '] ' + User.find_by(username: participant_name.u_name).name(ip_address) + ' '
participant.team_name_placeholder = participant_name.team_name
- participant.user_name_placeholder = User.find_by(name: participant_name.u_name).name(ip_address) + ' '
+ participant.user_name_placeholder = User.find_by(username: participant_name.u_name).name(ip_address) + ' '
team_name_added = true
end
end
diff --git a/app/models/student_task.rb b/app/models/student_task.rb
index d6394a83792..650050cba4c 100644
--- a/app/models/student_task.rb
+++ b/app/models/student_task.rb
@@ -114,7 +114,7 @@ def self.teamed_students(user, ip_address = nil)
teammates = []
course_id = Assignment.find_by(id: team.parent_id).course_id
- team_participants = Team.find(team.id).participants.reject { |p| p.name == user.name }
+ team_participants = Team.find(team.id).participants.reject { |p| p.name == user.username }
team_participants.each { |p| teammates << p.user.fullname(ip_address) }
next if teammates.empty?
diff --git a/app/models/team.rb b/app/models/team.rb
index 908a63cec29..5f777f1f896 100755
--- a/app/models/team.rb
+++ b/app/models/team.rb
@@ -78,7 +78,8 @@ def full?
# Add member to the team, changed to hash by E1776
def add_member(user, _assignment_id = nil)
- raise "The user #{user.name} is already a member of the team #{name}" if user?(user)
+ username = user.respond_to?(:username) ? user.username : user.name
+ raise "The user #{username} is already a member of the team #{name}" if user?(user)
can_add_member = false
unless full?
@@ -87,7 +88,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', user.name, "Added member to the team #{id}")
+ ExpertizaLogger.info LoggerMessage.new('Model:Team', username, "Added member to the team #{id}")
end
can_add_member
end
@@ -191,7 +192,7 @@ def self.generate_team_name(_team_name_prefix = '')
# Extract team members from the csv and push to DB, changed to hash by E1776
def import_team_members(row_hash)
row_hash[:teammembers].each_with_index do |teammate, _index|
- user = User.find_by(name: teammate.to_s)
+ user = User.find_by(username: teammate.to_s)
if user.nil?
raise ImportError, "The user '#{teammate}' was not found. Create this user?"
else
@@ -260,7 +261,7 @@ def self.export(csv, parent_id, options, teamtype)
if options[:team_name] == 'false'
team_members = TeamsUser.where(team_id: team.id)
team_members.each do |user|
- output.push(user.name)
+ output.push(user.user.username)
end
end
csv << output
diff --git a/app/models/teams_user.rb b/app/models/teams_user.rb
index 1309120a34a..b96be67f72d 100644
--- a/app/models/teams_user.rb
+++ b/app/models/teams_user.rb
@@ -6,7 +6,7 @@ class TeamsUser < ApplicationRecord
# attr_accessible :user_id, :team_id # unnecessary protected attributes
def name(ip_address = nil)
- name = user.name(ip_address)
+ name = user.username(ip_address)
# E2115 Mentor Management
# Indicate that someone is a Mentor in the UI. The view code is
diff --git a/app/models/user.rb b/app/models/user.rb
index 38e80f15b36..7d1bbae2eeb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -19,9 +19,9 @@ class User < ApplicationRecord
has_many :track_notifications, dependent: :destroy
belongs_to :parent, class_name: 'User'
belongs_to :role
- validates :name, presence: true
- validates :name, uniqueness: true
- validates :name, format: { without: /\s/ }
+ validates :username, presence: true
+ validates :username, uniqueness: { case_sensitive: false }
+ validates :username, format: { without: /\s/ }
validates :email, presence: { message: "can't be blank" }
validates :email, format: { with: /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\z/i, allow_blank: true }
@@ -48,9 +48,9 @@ def list_mine(object_type, user_id)
object_type.where(['instructor_id = ?', user_id])
end
- def get_available_users(name)
+ def get_available_users(username)
lesser_roles = role.get_parents
- all_users = User.all(conditions: ['name LIKE ?', "#{name}%"], limit: 20) # higher limit, since we're filtering
+ all_users = User.all(conditions: ['username LIKE ?', "#{username}%"], limit: 20) # higher limit, since we're filtering
visible_users = all_users.select { |user| lesser_roles.include? user.role }
visible_users[0, 10] # the first 10
end
@@ -107,13 +107,13 @@ def self.anonymized_view?(ip_address = nil)
# from their anonymized names. The process of obtaining
# real name is exactly opposite of what we'd do to get
# anonymized name from their real name.
- def self.real_user_from_anonymized_name(anonymized_name)
- user = User.find_by(name: anonymized_name)
+ def self.real_user_from_anonymized_username(anonymized_username)
+ user = User.find_by(username: anonymized_username)
user
end
- def name(ip_address = nil)
- User.anonymized_view?(ip_address) ? role.name + ' ' + id.to_s : self[:name]
+ def username(ip_address = nil)
+ User.anonymized_view?(ip_address) ? role.name + ' ' + id.to_s : self[:username]
end
def fullname(ip_address = nil)
@@ -164,7 +164,7 @@ def reset_password
def self.import(row_hash, _row_header, session, _id = nil)
raise ArgumentError, "Only #{row_hash.length} column(s) is(are) found. It must contain at least username, full name, email." if row_hash.length < 3
- user = User.find_by_name(row_hash[:username])
+ user = User.find_by_username(row_hash[:username])
if user.nil?
attributes = ImportFileHelper.define_attributes(row_hash)
user = ImportFileHelper.create_new_user(attributes, session)
@@ -195,7 +195,7 @@ def self.find_by_login(login)
if user.nil?
items = login.split('@')
short_name = items[0]
- user_list = User.where('name = ?', short_name)
+ user_list = User.where('username = ?', short_name)
user = user_list.first if user_list.any? && user_list.length == 1
end
user
@@ -257,9 +257,9 @@ def self.export(csv, _parent_id, options)
users = User.all
users.each do |user|
tcsv = []
- tcsv.push(user.name, user.fullname, user.email) if options['personal_details'] == 'true'
+ tcsv.push(user.username, user.fullname, user.email) if options['personal_details'] == 'true'
tcsv.push(user.role.name) if options['role'] == 'true'
- tcsv.push(user.parent.name) if options['parent'] == 'true'
+ tcsv.push(user.parent.username) if options['parent'] == 'true'
tcsv.push(user.email_on_submission, user.email_on_review, user.email_on_review_of_review, user.copy_of_emails) if options['email_options'] == 'true'
tcsv.push(user.etc_icons_on_homepage) if options['etc_icons_on_homepage'] == 'true'
tcsv.push(user.handle) if options['handle'] == 'true'
@@ -273,7 +273,7 @@ def creator
def self.export_fields(options)
fields = []
- fields.push('name', 'full name', 'email') if options['personal_details'] == 'true'
+ fields.push('username', 'full name', 'email') if options['personal_details'] == 'true'
fields.push('role') if options['role'] == 'true'
fields.push('parent') if options['parent'] == 'true'
fields.push('email on submission', 'email on review', 'email on metareview', 'copy of emails') if options['email_options'] == 'true'
@@ -286,7 +286,7 @@ def self.from_params(params)
user = if params[:user_id]
User.find(params[:user_id])
else
- User.find_by name: params[:user][:name]
+ User.find_by username: params[:user][:username]
end
if user.nil?
newuser = url_for controller: 'users', action: 'new'
@@ -312,14 +312,14 @@ def teaching_assistant?
end
def self.search_users(role, user_id, letter, search_by)
- key_word = { '1' => 'name', '2' => 'fullname', '3' => 'email' }
+ key_word = { '1' => 'username', '2' => 'fullname', '3' => 'email' }
sql = "(role_id in (?) or id = ?) and #{key_word[search_by]} like ?"
if key_word.include? search_by
search_filter = '%' + letter + '%'
- users = User.order('name').where(sql, role.get_available_roles, user_id, search_filter)
+ users = User.order('username').where(sql, role.get_available_roles, user_id, search_filter)
else # default used when clicking on letters
search_filter = letter + '%'
- users = User.order('name').where('(role_id in (?) or id = ?) and name like ?', role.get_available_roles, user_id, search_filter)
+ users = User.order('username').where('(role_id in (?) or id = ?) and username like ?', role.get_available_roles, user_id, search_filter)
end
users
end
diff --git a/app/views/account_request/list_pending_requested.html.erb b/app/views/account_request/list_pending_requested.html.erb
index 7f65e6fdfcb..bf2510b5d3b 100644
--- a/app/views/account_request/list_pending_requested.html.erb
+++ b/app/views/account_request/list_pending_requested.html.erb
@@ -19,7 +19,7 @@
<% @requested_users.each do |requested_user| %>
';
} else if (round_no == null && duty_id != undefined) {
- // E2147 : Add name of duty infront of the questionnaire type to select for which duty the questionnaire is being selected
+ // E2147 : Add name of duty in front of the questionnaire type to select for which duty the questionnaire is being selected
html += '
New password: <%= @password %>
diff --git a/app/views/mailer/partials/_author_conference_invitation_plain.html.erb b/app/views/mailer/partials/_author_conference_invitation_plain.html.erb
index 7e6348de421..ea5e87a79bf 100644
--- a/app/views/mailer/partials/_author_conference_invitation_plain.html.erb
+++ b/app/views/mailer/partials/_author_conference_invitation_plain.html.erb
@@ -4,7 +4,7 @@ Thank you for registering for [name of assignment]. To confirm your account, pl
After you have set up a password, you will be able to log in and submit your work.
We strongly recommend that you change the password the first time you access the application. Please update your profile.
-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address: <%= @user.email %>
New password: <%= @password %>
diff --git a/app/views/mailer/partials/_user_conference_invitation_html.html.erb b/app/views/mailer/partials/_user_conference_invitation_html.html.erb
index b176941be8d..3c3a2e3cf9e 100644
--- a/app/views/mailer/partials/_user_conference_invitation_html.html.erb
+++ b/app/views/mailer/partials/_user_conference_invitation_html.html.erb
@@ -9,6 +9,6 @@ Hi <%= @first_name %>,
-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address: <%= @user.email %>
New password: <%= @password %>
diff --git a/app/views/mailer/partials/_user_conference_invitation_plain.html.erb b/app/views/mailer/partials/_user_conference_invitation_plain.html.erb
index 4f0a095fcc0..86a94a9bb67 100644
--- a/app/views/mailer/partials/_user_conference_invitation_plain.html.erb
+++ b/app/views/mailer/partials/_user_conference_invitation_plain.html.erb
@@ -5,7 +5,7 @@ To confirm your account, please click on this link http://expertiza.ncsu.edu
After you have set up a password, you will be able to log in and access your co-author's work.
We strongly recommend that you change the password the first time you access the application. Please update your profile.
-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address: <%= @user.email %>
New password: <%= @password %>
diff --git a/app/views/mailer/partials/_user_welcome_html.html.erb b/app/views/mailer/partials/_user_welcome_html.html.erb
index 30a813892d4..b1f774de0a8 100644
--- a/app/views/mailer/partials/_user_welcome_html.html.erb
+++ b/app/views/mailer/partials/_user_welcome_html.html.erb
@@ -5,6 +5,6 @@ Hi <%= @first_name %>,
We strongly recommend that you change the password the first time you access the application.
-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address:<%= @user.email %>
New password: <%= @password %>
diff --git a/app/views/mailer/partials/_user_welcome_plain.html.erb b/app/views/mailer/partials/_user_welcome_plain.html.erb
index 4456bbd4ab0..351489c8420 100644
--- a/app/views/mailer/partials/_user_welcome_plain.html.erb
+++ b/app/views/mailer/partials/_user_welcome_plain.html.erb
@@ -4,7 +4,7 @@ Your Expertiza account has been created at http://expertiza.ncsu.edu .
We strongly recommend that you change the password the first time you
access the application.
-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address:<%= @user.email %>
New password: <%= @password %>
diff --git a/app/views/mailer/request_user_message.html.erb b/app/views/mailer/request_user_message.html.erb
index d361e024fa8..22b67a221ab 100644
--- a/app/views/mailer/request_user_message.html.erb
+++ b/app/views/mailer/request_user_message.html.erb
@@ -8,7 +8,7 @@ Hi <%= @first_name %>,
Below user requested to sign up. Review by going to Expertiza.