def test_get_by_schedule(self): regid = "9136CCB8F66711D5BE060004AC494FFE" term = Term() term.year = 2012 term.quarter = "summer" schedule = _get_schedule(regid, term) buildings = get_buildings_by_schedule(schedule) self.assertEquals(len(buildings), 3) term.year = 2001 schedule = _get_schedule(regid, term) buildings = get_buildings_by_schedule(schedule) self.assertEquals(buildings, None)
def test_get_by_schedule(self): regid = "9136CCB8F66711D5BE060004AC494FFE" term = Term() term.year = 2012 term.quarter = "summer" schedule = _get_schedule(regid, term) buildings = get_buildings_by_schedule(schedule) self.assertEquals(len(buildings), 3)
def load_schedule(request, schedule, summer_term=""): json_data = schedule.json_data() json_data["summer_term"] = summer_term colors = get_colors_by_schedule(schedule) buildings = get_buildings_by_schedule(schedule) canvas_data_by_course_id = [] try: canvas_data_by_course_id = get_indexed_by_decrosslisted( get_canvas_enrolled_courses(), schedule.sections) except Exception as ex: logger.error(ex) pass # Since the schedule is restclients, and doesn't know # about color ids, backfill that data section_index = 0 for section in schedule.sections: section_data = json_data["sections"][section_index] color = colors[section.section_label()] section_data["color_id"] = color section_index += 1 if EARLY_FALL_START == section.institute_name: section_data["early_fall_start"] = True json_data["has_early_fall_start"] = True # if section.is_primary_section: try: section_data["lib_subj_guide"] =\ get_subject_guide_by_section(section) except Exception as ex: logger.error(ex) pass if section.section_label() in canvas_data_by_course_id: enrollment = canvas_data_by_course_id[section.section_label()] # canvas_grade = enrollment.final_grade # section_data["canvas_grade"] = canvas_grade canvas_course = enrollment.course if not canvas_course.is_unpublished(): section_data["canvas_url"] = canvas_course.course_url section_data["canvas_name"] = canvas_course.name # MUWM-596 if section.final_exam and section.final_exam.building: building = buildings[section.final_exam.building] if building: section_data["final_exam"]["longitude"] = building.longitude section_data["final_exam"]["latitude"] = building.latitude section_data["final_exam"]["building_name"] = building.name # Also backfill the meeting building data meeting_index = 0 for meeting in section.meetings: try: mdata = section_data["meetings"][meeting_index] if not mdata["building_tbd"]: building = buildings[mdata["building"]] if building is not None: mdata["latitude"] = building.latitude mdata["longitude"] = building.longitude mdata["building_name"] = building.name for instructor in mdata["instructors"]: if ( not instructor["email1"] and not instructor["email2"] and not instructor["phone1"] and not instructor["phone2"] and not instructor["voicemail"] and not instructor["fax"] and not instructor["touchdial"] and not instructor["address1"] and not instructor["address2"] ): instructor["whitepages_publish"] = False meeting_index += 1 except IndexError as ex: pass # MUWM-443 json_data["sections"] = sorted(json_data["sections"], key=itemgetter('curriculum_abbr', 'course_number', 'section_id', )) # add section index index = 0 for section in json_data["sections"]: section["index"] = index index = index + 1 json_data["is_grad_student"] = is_grad_student() return json_data
def load_schedule(request, schedule, summer_term=""): filter_schedule_sections_by_summer_term(schedule, summer_term) json_data = schedule.json_data() json_data["summer_term"] = summer_term if len(schedule.sections) == 0: return json_data colors = get_colors_by_schedule(schedule) if colors is None and len(schedule.sections) > 0: return None buildings = get_buildings_by_schedule(schedule) # Removing call to Canvas pending MUWM-2106 # Too much! MUWM-2270 # canvas_data_by_course_id = [] canvas_data_by_primary_course_id = get_canvas_enrolled_courses() primary = canvas_data_by_primary_course_id canvas_data_by_course_id = get_indexed_by_decrosslisted(primary, schedule.sections) # Since the schedule is restclients, and doesn't know # about color ids, backfill that data section_index = 0 for section in schedule.sections: section_data = json_data["sections"][section_index] color = colors[section.section_label()] section_data["color_id"] = color section_index += 1 # if section.is_primary_section: section_data["lib_subj_guide"] = get_subject_guide_by_section(section) try: evaluation_json_data = json_for_evaluation( request, get_evaluations_by_section(section), section.summer_term ) except Exception as ex: evaluation_json_data = None if evaluation_json_data is not None: section_data["evaluation_data"] = evaluation_json_data if section.section_label() in canvas_data_by_course_id: enrollment = canvas_data_by_course_id[section.section_label()] canvas_url = enrollment.course_url canvas_name = enrollment.course_name # canvas_grade = enrollment.final_grade section_data["canvas_url"] = canvas_url section_data["canvas_name"] = canvas_name # section_data["canvas_grade"] = canvas_grade # MUWM-596 if section.final_exam and section.final_exam.building: building = buildings[section.final_exam.building] if building: section_data["final_exam"]["longitude"] = building.longitude section_data["final_exam"]["latitude"] = building.latitude section_data["final_exam"]["building_name"] = building.name # Also backfill the meeting building data meeting_index = 0 for meeting in section.meetings: try: mdata = section_data["meetings"][meeting_index] if not mdata["building_tbd"]: building = buildings[mdata["building"]] if building is not None: mdata["latitude"] = building.latitude mdata["longitude"] = building.longitude mdata["building_name"] = building.name for instructor in mdata["instructors"]: if ( not instructor["email1"] and not instructor["email2"] and not instructor["phone1"] and not instructor["phone2"] and not instructor["voicemail"] and not instructor["fax"] and not instructor["touchdial"] and not instructor["address1"] and not instructor["address2"] ): instructor["whitepages_publish"] = False meeting_index += 1 except IndexError as ex: pass # MUWM-443 json_data["sections"] = sorted( json_data["sections"], key=itemgetter("curriculum_abbr", "course_number", "section_id") ) json_data["is_grad_student"] = is_grad_student() return json_data
def load_schedule(request, schedule, summer_term=""): json_data = schedule.json_data() json_data["summer_term"] = summer_term colors = get_colors_by_schedule(schedule) buildings = get_buildings_by_schedule(schedule) canvas_data_by_course_id = [] try: canvas_data_by_course_id = get_indexed_by_decrosslisted( get_canvas_enrolled_courses(), schedule.sections) except Exception as ex: logger.error(ex) pass # Since the schedule is restclients, and doesn't know # about color ids, backfill that data section_index = 0 for section in schedule.sections: section_data = json_data["sections"][section_index] color = colors[section.section_label()] section_data["color_id"] = color section_index += 1 if EARLY_FALL_START == section.institute_name: section_data["early_fall_start"] = True json_data["has_early_fall_start"] = True # if section.is_primary_section: try: section_data["lib_subj_guide"] =\ get_subject_guide_by_section(section) except Exception as ex: logger.error(ex) pass if section.section_label() in canvas_data_by_course_id: enrollment = canvas_data_by_course_id[section.section_label()] # canvas_grade = enrollment.final_grade # section_data["canvas_grade"] = canvas_grade canvas_course = enrollment.course if not canvas_course.is_unpublished(): section_data["canvas_url"] = canvas_course.course_url section_data["canvas_name"] = canvas_course.name # MUWM-596 if section.final_exam and section.final_exam.building: building = buildings[section.final_exam.building] if building: section_data["final_exam"]["longitude"] = building.longitude section_data["final_exam"]["latitude"] = building.latitude section_data["final_exam"]["building_name"] = building.name # Also backfill the meeting building data meeting_index = 0 for meeting in section.meetings: try: mdata = section_data["meetings"][meeting_index] if not mdata["building_tbd"]: building = buildings[mdata["building"]] if building is not None: mdata["latitude"] = building.latitude mdata["longitude"] = building.longitude mdata["building_name"] = building.name for instructor in mdata["instructors"]: if (not instructor["email1"] and not instructor["email2"] and not instructor["phone1"] and not instructor["phone2"] and not instructor["voicemail"] and not instructor["fax"] and not instructor["touchdial"] and not instructor["address1"] and not instructor["address2"]): instructor["whitepages_publish"] = False meeting_index += 1 except IndexError as ex: pass # MUWM-443 json_data["sections"] = sorted(json_data["sections"], key=itemgetter( 'curriculum_abbr', 'course_number', 'section_id', )) # add section index index = 0 for section in json_data["sections"]: section["index"] = index index = index + 1 json_data["is_grad_student"] = is_grad_student() return json_data