Skip to content

Commit f756777

Browse files
committed
fixing issue with reassignment and adding blacklists to applicants page
1 parent 924c6c2 commit f756777

File tree

11 files changed

+88
-26
lines changed

11 files changed

+88
-26
lines changed

app/Charizard/util/Grader_Scoring.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def compute_grader_matching_weight(student: Student, course: Course):
1515

1616
if course.is_writing_or_comm_course and student.english_certification_level > 1:
1717
return Weights.NINFINITY
18+
19+
if student.email.lower().strip() in [email.lower().strip() for email in course.ta_deny_list]:
20+
return Weights.NINFINITY
1821

1922
weight += Scoring.score_ranked_ta_preference(student, course)
2023
weight += Scoring.score_gpa(student)

app/Charizard/util/SeniorGrader_Scoring.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def compute_senior_grader_matching_weight(student: Student, course: Course):
1515

1616
if course.is_writing_or_comm_course and student.english_certification_level > 1:
1717
return Weights.NINFINITY
18+
19+
if student.email.lower().strip() in [email.lower().strip() for email in course.ta_deny_list]:
20+
return Weights.NINFINITY
1821

1922
weight += Scoring.score_ranked_ta_preference(student, course)
2023
weight += Scoring.score_gpa(student)

app/Charizard/util/TA_Scoring.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def compute_ta_matching_weight(student: Student, course: Course) -> int:
1818
# needs to be taking at least this many hours
1919
if student.hours_enrolled < Scoring.MINIMUM_REQUIRED_HOURS or Scoring.is_instructor_and_ta_same(student, course):
2020
return Weights.NINFINITY
21+
22+
if student.email.lower().strip() in [email.lower().strip() for email in course.ta_deny_list]:
23+
return Weights.NINFINITY
2124

2225
weight += Scoring.score_ranked_ta_preference(student, course)
2326
weight += Scoring.score_gpa(student)
@@ -26,6 +29,7 @@ def compute_ta_matching_weight(student: Student, course: Course) -> int:
2629
weight += Scoring.score_previous_ta_for_course(student, course)
2730
weight += Scoring.score_courses_taken_at_tamu(student, course)
2831
weight += Scoring.score_based_on_priority_and_deny_list(student, course)
32+
2933
weight += Scoring.score_prereqs(student, course)
3034

3135
return weight

app/controllers/applicants_controller.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ def search_uin
8888
def show
8989
end
9090

91+
def toggle_blacklist
92+
@applicant = Applicant.find(params[:id])
93+
if @applicant.blacklisted?
94+
# Remove from blacklist
95+
Blacklist.where("LOWER(student_email) = ?", @applicant.email.downcase).destroy_all
96+
else
97+
# Add to blacklist
98+
Blacklist.create!(
99+
student_name: @applicant.name,
100+
student_email: @applicant.email
101+
)
102+
end
103+
redirect_back(fallback_location: applicants_path)
104+
end
105+
91106
# GET /applicants/new
92107
def new
93108
if session[:user_id].present?

app/controllers/blacklists_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ def create
2121
def destroy
2222
@blacklist = Blacklist.find(params[:id])
2323
@blacklist.destroy
24-
redirect_to blacklists_path, notice: "Student removed from blacklist."
24+
#redirect_to blacklists_path, notice: "Student removed from blacklist."
25+
respond_to do |format|
26+
format.turbo_stream
27+
format.html { redirect_to blacklists_path, notice: 'Removed from blacklist.' }
28+
end
2529
end
2630

2731
private

app/models/applicant.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def normalize_courses
7979
end
8080
end
8181
end
82+
83+
def blacklisted?
84+
Blacklist.exists?(["LOWER(student_email) = ?", email.downcase])
85+
end
8286

8387
def check_duplicates
8488
%i[prev_course prev_ta prev_uni].each do |field|

app/views/applicants/index.html.erb

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
<%# frozen_string_literal: true %>
22
<!DOCTYPE html>
33
<html lang="en">
44
<head>
@@ -51,6 +51,11 @@
5151
<table class="styled-table" style="min-width: 2000px;">
5252
<thead>
5353
<tr>
54+
<% if session[:role].to_s == "admin" %>
55+
<th>
56+
Blacklisted?
57+
</th>
58+
<% end %>
5459
<th>
5560
<%= link_to applicants_path(sort: "name", direction: toggle_direction("name")) do %>
5661
Name
@@ -169,30 +174,47 @@
169174
</thead>
170175
<tbody>
171176
<% @applicants.each do |applicant| %>
172-
<tr id="<%= dom_id applicant %>">
173-
<td class="<%= 'highlight-name' if applicant.name.start_with?('*') %>">
174-
<%= applicant.name %>
175-
</td>
176-
<td><%= applicant.email %></td>
177-
<td><%= applicant.degree %></td>
178-
<td><%= applicant.gpa %></td>
179-
<td><%= applicant.positions %></td>
180-
<td><%= applicant.number %></td>
181-
<td><%= applicant.uin %></td>
182-
<td><%= applicant.hours %></td>
183-
<td><%= applicant.citizenship %></td>
184-
<td><%= applicant.cert %></td>
185-
<td><%= applicant.prev_ta %></td>
186-
<td><%= applicant.prev_course %></td>
187-
<td><%= applicant.prev_uni %></td>
188-
<td><%= applicant.advisor %></td>
189-
<td>
177+
<%= turbo_frame_tag dom_id(applicant) do %>
178+
<tr id="<%= dom_id applicant %>">
190179
<% if session[:role].to_s == "admin" %>
191-
<%= link_to "Edit this applicant", edit_applicant_path(applicant), class: "action-button" %>
192-
<%end%>
193-
<%= link_to "Show this applicant", applicant_path(applicant), class: "table-link" %>
194-
</td>
195-
</tr>
180+
<td style="background-color: <%= applicant.blacklisted? ? 'rgb(243, 169, 162)' : 'rgb(162, 246, 156)' %>;">
181+
<% if applicant.blacklisted? %>
182+
<%= button_to "Unblacklist",
183+
toggle_blacklist_path(id: applicant.id),
184+
method: :post, remote: true,
185+
class: "btn btn-warning" %>
186+
<% else %>
187+
<%= button_to "Blacklist",
188+
toggle_blacklist_path(id: applicant.id),
189+
method: :post, remote: true,
190+
class: "btn btn-success" %>
191+
<% end %>
192+
</td>
193+
<% end %>
194+
<td class="<%= 'highlight-name' if applicant.name.start_with?('*') %>">
195+
<%= applicant.name %>
196+
</td>
197+
<td><%= applicant.email %></td>
198+
<td><%= applicant.degree %></td>
199+
<td><%= applicant.gpa %></td>
200+
<td><%= applicant.positions %></td>
201+
<td><%= applicant.number %></td>
202+
<td><%= applicant.uin %></td>
203+
<td><%= applicant.hours %></td>
204+
<td><%= applicant.citizenship %></td>
205+
<td><%= applicant.cert %></td>
206+
<td><%= applicant.prev_ta %></td>
207+
<td><%= applicant.prev_course %></td>
208+
<td><%= applicant.prev_uni %></td>
209+
<td><%= applicant.advisor %></td>
210+
<td>
211+
<% if session[:role].to_s == "admin" %>
212+
<%= link_to "Edit this applicant", edit_applicant_path(applicant), class: "action-button" %>
213+
<%end%>
214+
<%= link_to "Show this applicant", applicant_path(applicant), class: "table-link" %>
215+
</td>
216+
</tr>
217+
<% end %>
196218
<% end %>
197219
</tbody>
198220
</table>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
<%= turbo_stream.remove dom_id(@blacklist) %>

app/views/blacklists/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</thead>
4242
<tbody>
4343
<% @blacklisted_students.each do |student| %>
44-
<tr>
44+
<tr id="<%= dom_id(student) %>">
4545
<td><%= student.student_name %></td>
4646
<td><%= student.student_email %></td>
4747
<td>

app/views/layouts/application.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
<%= stylesheet_link_tag :app %>
2828
<%= javascript_importmap_tags %>
29+
<%= javascript_include_tag "application", type: "module" %>
30+
31+
2932
</head>
3033

3134
<body>

0 commit comments

Comments
 (0)