def build_display_appointments(today_date, teachers): # TODO take a look at this today date appointments = list() all_appointments = models.Appointment.query.filter_by(is_active=True).all() all_makeups = [app for app in all_appointments if app.is_makeup == True] all_absences = models.Absence.query.all() for app in all_appointments: if ( is_appointment_today(today_date, app) and not is_absent(today_date, app, all_absences) and not is_rescheduled(today_date, app, all_makeups) ): appointments.append(app) display_appointments = numpy.empty((len(teachers), len(timeslotHelp.get_timeslots()), 5), dtype=object) teacher_ids = [teacher.id for teacher in teachers] for appointment in appointments: # Skip the appointment if it is not from one of the teachers being displayed if appointment.teacher_id not in teacher_ids: continue for slot in timeslotHelp.timeslot_string_to_timeslot_num(appointment.times): for count in range(0, 5): if display_appointments[teacher_ids.index(appointment.teacher_id)][slot - 1][count] is None: display_appointments[teacher_ids.index(appointment.teacher_id)][slot - 1][count] = appointment break return display_appointments
def build_display_teacher_appointments(dates_of_week, current_teacher): display_appointments = numpy.empty((5, len(timeslotHelp.get_timeslots()), 5), dtype=object) teacher_appointments = models.Appointment.query.filter_by(teacher_id=current_teacher.id).all() # Remove makeup appointments and absences teacher_makeups = [app for app in teacher_appointments if app.is_makeup == True] all_absences = models.Absence.query.all() # Display all the appointments that are during that week for app in teacher_appointments: for idx, date in enumerate(dates_of_week): if is_appointment_today(date, app): for slot in timeslotHelp.timeslot_string_to_timeslot_num(app.times): for count in range(0, 5): # Add if not absent or rescheduled for that day if not is_teacher_appointment_absent( date, app, all_absences ) and not is_teacher_appointment_rescheduled(date, app, teacher_makeups): if display_appointments[idx][slot - 1][count] is None: display_appointments[idx][slot - 1][count] = app break return display_appointments
def get_timeslot_strings(times): timeslot_nums = timeslotHelp.timeslot_string_to_timeslot_num(times) time_strings = list() for num in timeslot_nums: time_strings.append(timeslotHelp.timeslot_num_to_time_string(num)) return time_strings