Skip to content

Commit

Permalink
auto accept previous year units
Browse files Browse the repository at this point in the history
  • Loading branch information
Incompleteusern committed Oct 26, 2023
1 parent b3b0738 commit da83239
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions roster/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,28 @@ def handle_inquiry(request: AuthHttpRequest, inquiry: UnitInquiry, student: Stud
)
return

unit = inquiry.unit

# auto accepting criteria for unlocking
if inquiry.action_type == "INQ_ACT_UNLOCK" and unlocked_count <= 9:
# when less than 6 past unlock (newbie) or a secret unit (currently uses subject to determine this)
auto_accept_criteria = (
num_past_unlock_inquiries <= 6 or inquiry.unit.group.subject == "K"
num_past_unlock_inquiries <= 6 or unit.group.subject == "K"
)

# check if its in previous years
# kind of assumes there's only one active semester
if not auto_accept_criteria and not student.curriculum.contains(unit):
all_students = Student.objects.filter(user=student.user)

for student in all_students:
print("STUDENT")
auto_accept_criteria |= student.unlocked_units.contains(unit)
print(student.unlocked_units.contains(unit))

elif inquiry.action_type == "INQ_ACT_DROP":
# auto dropping locked units
auto_accept_criteria = not student.unlocked_units.contains(inquiry.unit)
auto_accept_criteria = not student.unlocked_units.contains(unit)
else:
auto_accept_criteria = False

Expand Down

0 comments on commit da83239

Please sign in to comment.