Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/fullname to name #7

Merged
merged 19 commits into from
Oct 28, 2024
6 changes: 3 additions & 3 deletions app/controllers/account_request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def user_new(requested_user)
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
new_user.name = requested_user.name
new_user.email = requested_user.email
new_user.parent_id = session[:user].id
new_user.timezonepref = User.find_by(id: new_user.parent_id).timezonepref
Expand Down Expand Up @@ -148,7 +148,7 @@ def save_requested_user(requested_user, params)
def notify_supers_new_request(requested_user)
super_users = User.joins(:role).where('roles.name = ?', 'Super-Administrator')
super_users.each do |super_user|
prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user, requested_user, 'New Account Request: ' + requested_user.fullname)
prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user, requested_user, 'New Account Request: ' + requested_user.name)
prepared_mail.deliver
end
# Notifying an email to the administrator regarding the new user request!
Expand All @@ -163,7 +163,7 @@ def roles_for_request_sign_up
end

def requested_user_params
params.require(:user).permit(:username, :role_id, :fullname, :institution_id, :email)
params.require(:user).permit(:username, :role_id, :name, :institution_id, :email)
.merge(self_introduction: params[:requested_user][:self_introduction])
end
end
8 changes: 4 additions & 4 deletions app/controllers/import_file_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def import_from_hash(session, params)
# Produces an array, where each entry in the array is a hash.
# The hash keys are the column titles, and the hash values are the associated values.
#
# E.G. [ { :name => 'jsmith', :fullname => 'John Smith' , :email => '[email protected]' },
# { :name => 'jdoe', :fullname => 'Jane Doe', :email => '[email protected]' } ]
# E.G. [ { :name => 'jsmith', :name => 'John Smith' , :email => '[email protected]' },
# { :name => 'jdoe', :name => 'Jane Doe', :email => '[email protected]' } ]
#
def hash_rows_with_headers(header, body)
new_body = []
Expand Down Expand Up @@ -243,7 +243,7 @@ def hash_rows_with_headers(header, body)
# and :body refers to the contents of the file except the header.
# :header is an array, and :body is a two-dimensional array.
#
# E.G. { :header => ['name', 'fullname', 'email'],
# E.G. { :header => ['name', 'name', 'email'],
# :body => [ ['jsmith', 'John Smith', '[email protected]'],
# ['jdoe', 'Jane Doe', '[email protected]' ] ] }
#
Expand All @@ -263,7 +263,7 @@ def parse_to_hash(import_grid, has_header)
# The outer array contains "rows".
# The inner arrays contain "elements of rows" or "columns".
#
# E.G. [ [ 'name', 'fullname', 'email' ],
# E.G. [ [ 'name', 'name', 'email' ],
# [ 'jsmith', 'John Smith', '[email protected]' ],
# [ 'jdoe', 'Jane Doe', '[email protected]' ] ]
#
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def participant_params
def get_user_info(team_user, assignment)
user = {}
user[:username] = team_user.username
user[:fullname] = team_user.fullname
user[:name] = team_user.name
# set by default
permission_granted = false
assignment.participants.each do |participant|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/popup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def reviewer_details_popup
# this can be called from "response_report" by clicking reviewer names from instructor end.
def self_review_popup
@response_id = params[:response_id]
@user_fullname = params[:user_fullname]
@user_name = params[:user_name]
unless @response_id.nil?
first_question_in_questionnaire = Answer.where(response_id: @response_id).first.question_id
questionnaire_id = Question.find(first_question_in_questionnaire).questionnaire_id
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/profile_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def update
private

def user_params
params.require(:user).permit(:fullname,
params.require(:user).permit(:name,
:password,
:password_confirmation,
:email,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def list
case search_by.to_i
when 1 # Search by username
@paginated_users = paginate_list.where('username LIKE ?', "%#{letter}%")
when 2 # Search by fullname
@paginated_users = paginate_list.where('fullname LIKE ?', "%#{letter}%")
when 2 # Search by name
@paginated_users = paginate_list.where('name LIKE ?', "%#{letter}%")
when 3 # Search by email
@paginated_users = paginate_list.where('email LIKE ?', "%#{letter}%")
else
Expand Down Expand Up @@ -218,7 +218,7 @@ def user_params
:crypted_password,
:role_id,
:password_salt,
:fullname,
:name,
:email,
:parent_id,
:private_by_default,
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/conference_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def assign_user_params(is_author)

def user_params
params.require(:user).permit(:username,
:fullname,
:name,
:role_id,
:email,
:parent_id,
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/import_file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def self.define_attributes(row_hash)
attributes = {}
attributes['role_id'] = Role.student.id
attributes['username'] = row_hash[:username]
attributes['fullname'] = row_hash[:fullname]
attributes['name'] = row_hash[:name]
attributes['email'] = row_hash[:email]
attributes['email_on_submission'] = 1
attributes['email_on_review'] = 1
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/participants_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.define_attributes(line_split, config)
attributes = {}
attributes['role_id'] = Role.find_by name: 'Student'
attributes['username'] = line_split[config['username'].to_i]
attributes['fullname'] = config['fullname']
attributes['name'] = config['name']
attributes['email'] = line_split[config['email'].to_i]
attributes['password'] = (0...8).map { (65 + rand(26)).chr }.join
attributes['email_on_submission'] = 1
Expand Down Expand Up @@ -65,7 +65,7 @@ def self.get_config
while (line = infile.gets)
store_item(line, 'dlm', config)
store_item(line, 'username', config)
store_item(line, 'fullname', config)
store_item(line, 'name', config)
store_item(line, 'email', config)
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/review_mapping_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def link_updated_since_last?(round, due_dates, link_updated_at)
(link_updated_at < submission_due_date) && (link_updated_at > submission_due_last_round)
end

# For assignments with 1 team member, the following method returns user's fullname else it returns "team name" that a particular reviewee belongs to.
# For assignments with 1 team member, the following method returns user's name else it returns "team name" that a particular reviewee belongs to.
def get_team_reviewed_link_name(max_team_size, _response, reviewee_id, ip_address)
team_reviewed_link_name = if max_team_size == 1
TeamsUser.where(team_id: reviewee_id).first.user.fullname(ip_address)
TeamsUser.where(team_id: reviewee_id).first.user.name(ip_address)
else
# E1991 : check anonymized view here
Team.find(reviewee_id).name
Expand Down
2 changes: 1 addition & 1 deletion app/models/account_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class AccountRequest < ApplicationRecord
format: { with: VALID_EMAIL_REGEX, message: 'format is wrong' },
uniqueness: { case_sensitive: false, message: 'has already existed in Expertiza' }

validates :fullname, presence: true, length: { maximum: 100, message: 'is too long' }
validates :name, presence: true, length: { maximum: 100, message: 'is too long' }
end
2 changes: 1 addition & 1 deletion app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def self.export_data(csv, scores, options)
teams_csv << team[:team].name
names_of_participants = ''
team[:team].participants.each do |p|
names_of_participants += p.fullname
names_of_participants += p.name
names_of_participants += '; ' unless p == team[:team].participants.last
end
teams_csv << names_of_participants
Expand Down
2 changes: 1 addition & 1 deletion app/models/feedback_response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def email(defn, _participant, assignment)
user = User.find(participant.user_id)

defn[:to] = user.email
defn[:body][:first_name] = user.fullname
defn[:body][:first_name] = user.name
Mailer.sync_message(defn).deliver
end
end
4 changes: 2 additions & 2 deletions app/models/mentor_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def self.assign_mentor(assignment_id, team_id)
def self.notify_team_of_mentor_assignment(mentor, team)
members = team.users
emails = members.map(&:email)
members_info = members.map { |mem| "#{mem.fullname} - #{mem.email}" }
mentor_info = "#{mentor.fullname} (#{mentor.email})"
members_info = members.map { |mem| "#{mem.name} - #{mem.email}" }
mentor_info = "#{mentor.name} (#{mentor.email})"
message = "#{mentor_info} has been assigned as your mentor for assignment #{Assignment.find(team.parent_id).name} <br>Current members:<br> #{members_info.join('<br>')}"

Mailer.delayed_message(bcc: emails,
Expand Down
2 changes: 1 addition & 1 deletion app/models/metareview_response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def email(defn, _participant, assignment)
defn[:body][:type] = 'Metareview'
reviewee_user = Participant.find(reviewee_id)
defn[:body][:obj_name] = assignment.name
defn[:body][:first_name] = User.find(reviewee_user.user_id).fullname
defn[:body][:first_name] = User.find(reviewee_user.user_id).name
defn[:to] = User.find(reviewee_user.user_id).email
Mailer.sync_message(defn).deliver
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def name(ip_address = nil)
end

def fullname(ip_address = nil)
user.fullname(ip_address)
user.name(ip_address)
end

def handle(ip_address = nil)
Expand Down Expand Up @@ -136,7 +136,7 @@ def self.export(csv, parent_id, options)
where(parent_id: parent_id).find_each do |part|
tcsv = []
user = part.user
tcsv.push(user.username, user.fullname, user.email) if options['personal_details'] == 'true'
tcsv.push(user.username, user.name, user.email) if options['personal_details'] == 'true'
tcsv.push(user.role.name) if options['role'] == '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'
Expand Down
4 changes: 2 additions & 2 deletions app/models/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ def notify_instructor_on_difference
response_map = map
reviewer_participant_id = response_map.reviewer_id
reviewer_participant = AssignmentParticipant.find(reviewer_participant_id)
reviewer_name = User.find(reviewer_participant.user_id).fullname
reviewer_name = User.find(reviewer_participant.user_id).name
reviewee_team = AssignmentTeam.find(response_map.reviewee_id)
reviewee_participant = reviewee_team.participants.first # for team assignment, use the first member's name.
reviewee_name = User.find(reviewee_participant.user_id).fullname
reviewee_name = User.find(reviewee_participant.user_id).name
assignment = Assignment.find(reviewer_participant.parent_id)
Mailer.notify_grade_conflict_message(
to: assignment.instructor.email,
Expand Down
2 changes: 1 addition & 1 deletion app/models/response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def self.assessments_for(team)
@array_sort.clear
@sort_to.clear
end
responses = responses.sort { |a, b| a.map.reviewer.fullname <=> b.map.reviewer.fullname }
responses = responses.sort { |a, b| a.map.reviewer.name <=> b.map.reviewer.name }
end
responses
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/review_questionnaire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_assessments_round_for(participant, round)
end
end
# responses = Response.find(:all, :include => :map, :conditions => ['reviewee_id = ? and type = ?',participant.id, self.to_s])
responses.sort! { |a, b| a.map.reviewer.fullname <=> b.map.reviewer.fullname }
responses.sort! { |a, b| a.map.reviewer.name <=> b.map.reviewer.name }
end
responses
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/review_response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def self.get_responses_for_team_round(team, round)
responses << map.response.reject { |r| (r.round != round || !r.is_submitted) }.last
end
end
responses.sort! { |a, b| a.map.reviewer.fullname <=> b.map.reviewer.fullname }
responses.sort! { |a, b| a.map.reviewer.name <=> b.map.reviewer.name }
end
responses
end
Expand Down Expand Up @@ -149,7 +149,7 @@ def self.review_response_report(id, assignment, type, review_user)
end
else
# This is a search, so find reviewers by user's full name
user_ids = User.select('DISTINCT id').where('fullname LIKE ?', '%' + review_user[:fullname] + '%')
user_ids = User.select('DISTINCT id').where('name LIKE ?', '%' + review_user[:name] + '%')
# E1973 - we use a separate query depending on if the reviewer is a team or participant
if assignment.team_reviewing_enabled
reviewer_participants = AssignmentTeam.where('id IN (?) and parent_id = ?', team_ids, assignment.id)
Expand All @@ -171,7 +171,7 @@ def email(defn, _participant, assignment)
defn[:body][:type] = 'Peer Review'
AssignmentTeam.find(reviewee_id).users.each do |user|
defn[:body][:obj_name] = assignment.name
defn[:body][:first_name] = User.find(user.id).fullname
defn[:body][:first_name] = User.find(user.id).name
defn[:to] = User.find(user.id).email
Mailer.sync_message(defn).deliver_now
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/student_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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.username }
team_participants.each { |p| teammates << p.user.fullname(ip_address) }
team_participants.each { |p| teammates << p.user.name(ip_address) }
next if teammates.empty?

if students_teamed[course_id].nil?
Expand Down
2 changes: 1 addition & 1 deletion app/models/survey_response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def email(defn, participant, survey_parent)
user = User.find(participant.user_id)
defn[:body][:type] = 'Survey Submission'
defn[:body][:obj_name] = survey_parent.name
defn[:body][:first_name] = user.fullname
defn[:body][:first_name] = user.name
defn[:to] = user.email
Mailer.sync_message(defn).deliver_now
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def node_type
def author_names
names = []
users.each do |user|
names << user.fullname
names << user.name
end
names
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/teammate_review_response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def email(defn, _participant, assignment)
participant = AssignmentParticipant.find(reviewee_id)
defn[:body][:obj_name] = assignment.name
user = User.find(participant.user_id)
defn[:body][:first_name] = user.fullname
defn[:body][:first_name] = user.name
defn[:to] = user.email
Mailer.sync_message(defn).deliver
end
Expand Down
14 changes: 7 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class User < ApplicationRecord
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 }

validates :fullname, presence: true
validates :name, presence: true

before_validation :randomize_password, if: ->(user) { user.new_record? && user.password.blank? } # AuthLogic

Expand Down Expand Up @@ -116,12 +116,12 @@ def username(ip_address = nil)
User.anonymized_view?(ip_address) ? role.name + ' ' + id.to_s : self[:username]
end

def fullname(ip_address = nil)
User.anonymized_view?(ip_address) ? role.name + ', ' + id.to_s : self[:fullname]
def name(ip_address = nil)
User.anonymized_view?(ip_address) ? role.name + ', ' + id.to_s : self[:name]
end

def first_name(ip_address = nil)
User.anonymized_view?(ip_address) ? role.name : fullname.try(:[], /,.+/).try(:[], /\w+/) || ''
User.anonymized_view?(ip_address) ? role.name : name.try(:[], /,.+/).try(:[], /\w+/) || ''
end

def email(ip_address = nil)
Expand Down Expand Up @@ -170,7 +170,7 @@ def self.import(row_hash, _row_header, session, _id = nil)
user = ImportFileHelper.create_new_user(attributes, session)
else
user.email = row_hash[:email]
user.fullname = row_hash[:fullname]
user.name = row_hash[:name]
user.parent_id = (session[:user]).id
user.save
end
Expand Down Expand Up @@ -257,7 +257,7 @@ def self.export(csv, _parent_id, options)
users = User.all
users.each do |user|
tcsv = []
tcsv.push(user.username, user.fullname, user.email) if options['personal_details'] == 'true'
tcsv.push(user.username, user.name, user.email) if options['personal_details'] == 'true'
tcsv.push(user.role.name) if options['role'] == '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'
Expand Down Expand Up @@ -312,7 +312,7 @@ def teaching_assistant?
end

def self.search_users(role, user_id, letter, search_by)
key_word = { '1' => 'username', '2' => 'fullname', '3' => 'email' }
key_word = { '1' => 'username', '2' => 'name', '3' => 'email' }
sql = "(role_id in (?) or id = ?) and #{key_word[search_by]} like ?"
if key_word.include? search_by
search_filter = '%' + letter + '%'
Expand Down
2 changes: 1 addition & 1 deletion app/views/account_request/list_pending_requested.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<% @requested_users.each do |requested_user| %>
<tr class="exp">
<td><%= requested_user.username %></td>
<td><%= requested_user.fullname %></td>
<td><%= requested_user.name %></td>
<td><%= mail_to requested_user.email, requested_user.email %></td>
<td><%= Role.find_by(id: requested_user.role_id).try(:name) %></td>
<td style = "width:20%"><div class = "comment"><%= requested_user.self_introduction %></div></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<%= form_tag action: :create_approved_user, id: requested_user.id do %>
<tr class="exp">
<td><%= requested_user.username %></td>
<td><%= requested_user.fullname %></td>
<td><%= requested_user.name %></td>
<td><%= mail_to requested_user.email, requested_user.email %></td>
<td><%= Role.find_by(id: requested_user.role_id).try(:name) %></td>
<td style = "width:20%"><div class = "comment"><%= requested_user.self_introduction %></div></td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<table>

<tr><th>Full Name:</th>
<td><%= @user.fullname(session[:ip]) %></td>
<td><%= @user.name(session[:ip]) %></td>
</tr>

<tr><th>Email Address:</th>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/list_administrators.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<tr>
<td><%= link_to user.username(session[:ip]), :action => 'show_administrator',
:id => user.id %></td><td> </td>
<td><%= user.fullname(session[:ip]) %></td><td> </td>
<td><%= user.name(session[:ip]) %></td><td> </td>
<td><%= user.email(session[:ip]) %></td><td> </td>
<td><%= (User.find(user.parent_id)).username %></td><td> </td>
</tr>
Expand Down
Loading
Loading