[docs]defstart_date(request):"""Add the start date to the context for eighth admins. Args: request: The request object Returns: The start date if an eighth_admin, an empty dictionary otherwise. """ifrequest.userandrequest.user.is_authenticatedandrequest.user.is_eighth_admin:return{"admin_start_date":get_start_date(request)}return{}
[docs]defenable_waitlist(request):"""Add whether the waitlist is enabled to the context. Args: request: The request object Returns: bool: Whether the waitlist is enabled. """return{"waitlist_enabled":settings.ENABLE_WAITLIST}
[docs]defabsence_count(request):"""Add the absence count to the context for students. Args: request: The request object Returns: Number of absences that a student has if a student, an empty dictionary otherwise. """ifrequest.userandrequest.user.is_authenticatedandrequest.user.is_student:absence_info=request.user.absence_info()num_absences=absence_info.count()show_notif=Falseifnum_absencesandnotrequest.session.get("eighth_absence_notif_seen",False):show_notif=any(signup.in_clear_absence_period()forsignupinabsence_info)ifshow_notif:request.session["eighth_absence_notif_seen"]=Truereturn{"eighth_absence_count":num_absences,"eighth_absence_notif":show_notif}return{}