Skip to content

Commit

Permalink
Enforce lecture attendance for early winter trips
Browse files Browse the repository at this point in the history
We previously didn't require lecture attendance for winter trips that
run before Winter School itself. There's been a change in guidelines
now, though! There are special "early" lectures that can be run in the
fall. For now, I'm recording attendance to those lectures via direct db
writes. Additionally, attendance to *last* year's lectures is valid.
  • Loading branch information
DavidCain committed Dec 7, 2024
1 parent 88ed49f commit 33966cc
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 42 deletions.
24 changes: 22 additions & 2 deletions ws/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,33 @@ def missed_lectures(self, year: int) -> bool:
def missed_lectures_for(self, trip: "Trip") -> bool:
"""Should we regard the participant as having missed lectures for this trip.
This only applies to WS trips - all other trips will return False.
This only applies to winter trips - all other trips will return False.
During the first week of Winter School (where people sign up for trips
_before_ being marked as having attended lectures), we don't want to consider
people as having missed lectures.
"""
# Notably, winter trips outside IAP don't require lecture attendance
# ~December trips (before IAP) are a special case.
# Lecture attendance is required, but two different years can both work!
if trip.program_enum == enums.Program.WINTER_NON_IAP:
today = date_utils.local_date()
allowed_years = {
# Attendance to the same calendar year's lectures is *always* valid.
# In December of 2024, lectures from Jan 2024 are valid.
# In January of 2025, lectures from Jan 2025 are valid.
today.year,
# Special ~November/December lectures are recorded as being for the *next* cal year.
# (e.g. November 2024 lectures are recorded as being for WS 2025)
today.year + 1,
}
# If it's January, we also allow last year's WS.
if today.month == 1:
allowed_years.add(today.year - 1)

return not self.lectureattendance_set.filter(
year__in=allowed_years
).exists()

if trip.program_enum != enums.Program.WINTER_SCHOOL:
return False

Expand Down
Loading

0 comments on commit 33966cc

Please sign in to comment.