Example #1
0
    def test_get_subject_guide_seattle(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '101':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/research")

                # has subject guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '100':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/friendly.php?s=research/pnw")

                # has subject guide link
                if section.curriculum_abbr == 'PHYS' and\
                        section.course_number == '121':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "%s?%s" % ("http://guides.lib.uw.edu/friendly.php",
                                   "s=research/physics_astronomy"))
Example #2
0
    def test_get_subject_guide_tacoma(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "12345678901234567890123456789012"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'ROLING' and\
                        section.course_number == '310':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/tacoma")

                if section.curriculum_abbr == 'T ARTS' and\
                        section.course_number == '110':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/tacoma")

                # has subject guide link
                if section.curriculum_abbr == 'ARCTIC' and\
                        section.course_number == '200':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/tacoma/art")
Example #3
0
    def test_get_subject_guide_tacoma(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "12345678901234567890123456789012"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'ROLING' and\
                        section.course_number == '310':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/tacoma")

                if section.curriculum_abbr == 'T ARTS' and\
                        section.course_number == '110':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/tacoma")

                # has subject guide link
                if section.curriculum_abbr == 'ARCTIC' and\
                        section.course_number == '200':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/tacoma/art")
Example #4
0
    def test_get_subject_guide_seattle(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '101':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/research")

                # has subject guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '100':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/friendly.php?s=research/pnw")

                # has subject guide link
                if section.curriculum_abbr == 'PHYS' and\
                        section.course_number == '121':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "%s?%s" % ("http://guides.lib.uw.edu/friendly.php",
                                   "s=research/physics_astronomy"))
Example #5
0
 def test_get_subject_guide_by_section(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         term = Term()
         term.year = 2013
         term.quarter = "spring"
         schedule = _get_schedule(regid, term)
         for section in schedule.sections:
             if section.curriculum_abbr == 'TRAIN':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://www.lib.washington.edu/subject/")
             if section.curriculum_abbr == 'PHYS':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.washington.edu/physics_astronomy")
Example #6
0
 def test_get_subject_guide_bothell(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "FE36CCB8F66711D5BE060004AC494FCD"
         term = Term()
         term.year = 2013
         term.quarter = "spring"
         schedule = _get_schedule(regid, term)
         for section in schedule.sections:
             # has subject guide link
             if section.curriculum_abbr == 'BISSEB' and\
                     section.course_number == '259':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.uw.edu/bothell/businternational")
             # 404, general guide link
             if section.curriculum_abbr == 'BCWRIT' and\
                     section.course_number == '500':
                 self.assertEquals(get_subject_guide_by_section(section),
                                   "http://guides.lib.uw.edu/bothell/")
Example #7
0
 def test_get_subject_guide_bothell(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "FE36CCB8F66711D5BE060004AC494FCD"
         term = Term()
         term.year = 2013
         term.quarter = "spring"
         schedule = _get_schedule(regid, term)
         for section in schedule.sections:
             # has subject guide link
             if section.curriculum_abbr == 'BISSEB' and\
                     section.course_number == '259':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.uw.edu/bothell/businternational")
             # 404, general guide link
             if section.curriculum_abbr == 'BCWRIT' and\
                     section.course_number == '500':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.uw.edu/bothell/")
Example #8
0
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
Example #9
0
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
Example #10
0
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