diff --git a/app/controllers/account_request_controller.rb b/app/controllers/account_request_controller.rb
index 4fc02c07c9a..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.username = 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(username: requested_user.name)) || User.find_by(username: 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/models/account_request.rb b/app/models/account_request.rb
index 85e5a3a18dd..6265912a25b 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' }
+ 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/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| %>
- <%= requested_user.name %> |
+ <%= requested_user.username %> |
<%= requested_user.fullname %> |
<%= mail_to requested_user.email, requested_user.email %> |
<%= Role.find_by(id: requested_user.role_id).try(:name) %> |
diff --git a/app/views/account_request/list_pending_requested_finalized.html.erb b/app/views/account_request/list_pending_requested_finalized.html.erb
index 853e73da349..6b0fd73423d 100644
--- a/app/views/account_request/list_pending_requested_finalized.html.erb
+++ b/app/views/account_request/list_pending_requested_finalized.html.erb
@@ -9,7 +9,7 @@
<% @requested_users.each do |requested_user| %>
<%= form_tag action: :create_approved_user, id: requested_user.id do %>
- <%= requested_user.name %> |
+ <%= requested_user.username %> |
<%= requested_user.fullname %> |
<%= mail_to requested_user.email, requested_user.email %> |
<%= Role.find_by(id: requested_user.role_id).try(:name) %> |
diff --git a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb
index bf3d88a36fc..8d22f973eb0 100644
--- a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb
+++ b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb
@@ -2,6 +2,6 @@ class RenameNameAndFullnameInUsers < ActiveRecord::Migration[5.1]
def change
# Renaming columns
rename_column :users, :name, :username
- rename_column :users, :fullname, :name
+ rename_column :account_requests, :name, :username
end
end
\ No newline at end of file
diff --git a/db/schema.rb b/db/schema.rb
index 83a64cc8a04..7f2c00ba68a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -13,7 +13,7 @@
ActiveRecord::Schema.define(version: 20241009142307) do
create_table "account_requests", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
- t.string "name"
+ t.string "username"
t.integer "role_id"
t.string "fullname"
t.string "institution_id"
@@ -977,7 +977,7 @@
t.string "crypted_password", limit: 40, default: "", null: false
t.integer "role_id", default: 0, null: false
t.string "password_salt"
- t.string "name"
+ t.string "fullname"
t.string "email"
t.integer "parent_id"
t.boolean "private_by_default", default: false
diff --git a/spec/controllers/account_request_controller_spec.rb b/spec/controllers/account_request_controller_spec.rb
index e401edbd1bb..5409d0d21a7 100644
--- a/spec/controllers/account_request_controller_spec.rb
+++ b/spec/controllers/account_request_controller_spec.rb
@@ -11,7 +11,7 @@
let(:institution1) { build(:institution, id: 1) }
let(:requested_user1) do
- AccountRequest.new id: 4, name: 'requester1', role_id: 2, fullname: 're, requester1',
+ AccountRequest.new id: 4, username: 'requester1', role_id: 2, fullname: 're, requester1',
institution_id: 1, email: 'requester1@test.com', status: nil, self_introduction: 'no one'
end
let(:superadmin) { build(:superadmin) }
diff --git a/spec/controllers/conference_controller_spec.rb b/spec/controllers/conference_controller_spec.rb
index 61093dae232..f34ace1ced3 100644
--- a/spec/controllers/conference_controller_spec.rb
+++ b/spec/controllers/conference_controller_spec.rb
@@ -14,7 +14,7 @@
let(:institution1) { build(:institution, id: 1) }
let(:assignment1) { build(:assignment, id: 2, is_conference_assignment: 1, max_team_size: 100) }
let(:requested_user1) do
- AccountRequest.new id: 4, name: 'requester1', role_id: 2, fullname: 're, requester1',
+ AccountRequest.new id: 4, username: 'requester1', role_id: 2, fullname: 're, requester1',
institution_id: 1, email: 'requester1@test.com', status: nil, self_introduction: 'no one'
end
let(:superadmin) { build(:superadmin) }
@@ -62,7 +62,7 @@
it 'save successfully for existing user as Author' do
request_params = {
- user: { name: 'lily',
+ user: { username: 'lily',
assignment: '2' }
}
allow(User).to receive(:find_by).with(name: 'lily').and_return(student1)
@@ -75,7 +75,7 @@
end
it 'return error if user email already exist' do
request_params = {
- user: { name: 'lily',
+ user: { username: 'lily',
role_id: 2,
email: 'chenzy@gmail.com',
fullname: 'John Bumgardner',
@@ -88,7 +88,7 @@
post :create, params: request_params
request_params2 = {
- user: { name: 'lily23',
+ user: { username: 'lily23',
role_id: 2,
email: 'chenzy@gmail.com',
fullname: 'John Bumgardner',
@@ -106,7 +106,7 @@
it 'should redirect to root with correct recaptcha' do
user_session = { user: student1 }
request_params = {
- user: { name: 'lily',
+ user: { username: 'lily',
crypted_password: 'password',
role_id: 1,
password_salt: 1,
@@ -136,7 +136,7 @@
it 'should redirect to join conference page with incorrect recaptcha' do
user_session = { user: student2 }
request_params = {
- user: { name: 'lily2',
+ user: { username: 'lily2',
crypted_password: 'password',
role_id: 1,
password_salt: 1,
diff --git a/spec/controllers/courses_controller_spec.rb b/spec/controllers/courses_controller_spec.rb
index 26d74c1c098..9779c509486 100644
--- a/spec/controllers/courses_controller_spec.rb
+++ b/spec/controllers/courses_controller_spec.rb
@@ -155,7 +155,7 @@
allow(Role).to receive(:find_by_name).with('Teaching Assistant').and_return(true)
allow(user).to receive(:save).and_return(true)
- params = { course_id: 1, user: { name: 'Teaching Assistant' } }
+ params = { course_id: 1, user: { username: 'Teaching Assistant' } }
post :add_ta, params: params
expect(response).to be_redirect
end
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 2f6486d0436..b2e741f39d9 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -12,7 +12,7 @@
let(:institution1) { build(:institution, id: 1) }
let(:requested_user1) do
- AccountRequest.new id: 4, name: 'requester1', role_id: 2, fullname: 're, requester1',
+ AccountRequest.new id: 4, username: 'requester1', role_id: 2, fullname: 're, requester1',
institution_id: 1, email: 'requester1@test.com', status: nil, self_introduction: 'no one'
end
let(:superadmin) { build(:superadmin) }
diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb
index 59220209b23..dbcb358029d 100644
--- a/spec/factories/factories.rb
+++ b/spec/factories/factories.rb
@@ -572,7 +572,7 @@
end
factory :requested_user, class: AccountRequest do
- name 'requester1'
+ username 'requester1'
role_id 2
fullname 'requester, requester'
institution_id 1
diff --git a/spec/features/account_request_spec.rb b/spec/features/account_request_spec.rb
index 33fa359e0f2..071d3c89542 100644
--- a/spec/features/account_request_spec.rb
+++ b/spec/features/account_request_spec.rb
@@ -36,7 +36,7 @@
fill_in 'user_email', with: 'test@test.com'
expect { click_on 'Request' }.to change { AccountRequest.count }.by(1)
- expect(AccountRequest.first.name).to eq('requester')
+ expect(AccountRequest.first.username).to eq('requester')
expect(AccountRequest.first.role_id).to eq(3)
expect(AccountRequest.first.fullname).to eq('requester, requester')
expect(AccountRequest.first.email).to eq('test@test.com')