Skip to content

Commit f1c9dec

Browse files
committed
Add assistants by email
1 parent 1945ff3 commit f1c9dec

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/controllers/setup/course_assistants_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def create
2121
authorize! :modify_assistants, @course
2222

2323
if params[:commit] == 'Add new assistant'
24-
new_assistant = User.find_by(login: assistant_params[:username])
24+
new_assistant = User.find_by('lower(email) = ?', assistant_params[:email].downcase)
2525
@assistantship = Assistantship.new(user: new_assistant, course: @course)
2626

2727
if @assistantship.save
@@ -54,6 +54,6 @@ def destroy
5454
private
5555

5656
def assistant_params
57-
params.permit(:username)
57+
params.permit(:email)
5858
end
5959
end

app/views/setup/course_assistants/index.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<%= render 'shared/error_messages', target: @assistantship %>
2121

2222
<div class="field">
23-
<%= label_tag :username, "Enter assistant's username:" %>
24-
<%= text_field_tag :username, nil, class: 'form-control' %>
23+
<%= label_tag :email, "Enter assistant's email:" %>
24+
<%= text_field_tag :email, nil, class: 'form-control' %>
2525
</div>
2626
<br>
2727
<div class="actions">
@@ -50,7 +50,7 @@
5050
<tbody>
5151
<% @assistants.each do |assistant| %>
5252
<tr>
53-
<td><%= link_to assistant.username, participant_path(assistant) %></td>
53+
<td><%= link_to assistant.email, participant_path(assistant) %></td>
5454
<td><%= link_to 'Remove', setup_organization_course_course_assistant_path(@course.organization, @course, assistant.assistantship(@course)), method: :delete, class: "btn btn-sm btn-warning", data: { confirm: 'Are you sure?' } %></td>
5555
</tr>
5656
<% end %>

0 commit comments

Comments
 (0)