Example #1
0
def _get_registered_summer_terms(registered_summer_sections):
    """
    Return all the summer terms in the registered summer sections
    """
    data = {
        FULL_TERM: False,
        A_TERM: False,
        B_TERM: False,
        FULL_TERM_CREDITS: 0,
        A_TERM_CREDITS: 0,
        B_TERM_CREDITS: 0,
        FULL_TERM_SECTIONS: 0,
        A_TERM_SECTIONS: 0,
        B_TERM_SECTIONS: 0,
        }
    for section in registered_summer_sections:
        if is_full_summer_term(section.summer_term):
            data[FULL_TERM] = True
            data[FULL_TERM_SECTIONS] = data[FULL_TERM_SECTIONS] + 1
            data[FULL_TERM_CREDITS] = (data[FULL_TERM_CREDITS] +
                                       section.student_credits)
        elif is_a_term(section.summer_term):
            data[A_TERM] = True
            data[A_TERM_SECTIONS] = data[A_TERM_SECTIONS] + 1
            data[A_TERM_CREDITS] = (data[A_TERM_CREDITS] +
                                    section.student_credits)
        elif is_b_term(section.summer_term):
            data[B_TERM] = True
            data[B_TERM_SECTIONS] = data[B_TERM_SECTIONS] + 1
            data[B_TERM_CREDITS] = (data[B_TERM_CREDITS] +
                                    section.student_credits)
        else:
            pass
    return data
Example #2
0
def _get_future_term_json(term, summer_term, summer_term_data=None):
    return_json = term.json_data()
    return_json["summer_term"] = summer_term
    url = "/" + str(term.year) + "," + term.quarter
    if len(summer_term) > 0:
        url = url + "," + summer_term.lower()

        if is_a_term(summer_term):
            return_json["credits"] = str(summer_term_data[FULL_TERM_CREDITS] +
                                         summer_term_data[A_TERM_CREDITS])

            section_count = (summer_term_data[FULL_TERM_SECTIONS] +
                             summer_term_data[A_TERM_SECTIONS])
            return_json["section_count"] = section_count
        elif is_b_term(summer_term):
            return_json["credits"] = str(summer_term_data[FULL_TERM_CREDITS] +
                                         summer_term_data[B_TERM_CREDITS])

            section_count = (summer_term_data[FULL_TERM_SECTIONS] +
                             summer_term_data[B_TERM_SECTIONS])
            return_json["section_count"] = section_count
        elif is_full_summer_term(summer_term):
            return_json["credits"] = str(summer_term_data[FULL_TERM_CREDITS])
            return_json["section_count"] = summer_term_data[FULL_TERM_SECTIONS]
    else:
        return_json["credits"] = str(term.credits)
        return_json["section_count"] = term.section_count

    return_json["url"] = url
    return return_json
Example #3
0
def _get_registered_summer_terms(registered_summer_sections):
    """
    Return all the summer terms in the registered summer sections
    """
    data = {
        FULL_TERM: False,
        A_TERM: False,
        B_TERM: False,
        FULL_TERM_CREDITS: 0,
        A_TERM_CREDITS: 0,
        B_TERM_CREDITS: 0,
        FULL_TERM_SECTIONS: 0,
        A_TERM_SECTIONS: 0,
        B_TERM_SECTIONS: 0,
    }
    for section in registered_summer_sections:
        if is_full_summer_term(section.summer_term):
            data[FULL_TERM] = True
            data[FULL_TERM_SECTIONS] = data[FULL_TERM_SECTIONS] + 1
            data[FULL_TERM_CREDITS] = (data[FULL_TERM_CREDITS] +
                                       section.student_credits)
        elif is_a_term(section.summer_term):
            data[A_TERM] = True
            data[A_TERM_SECTIONS] = data[A_TERM_SECTIONS] + 1
            data[A_TERM_CREDITS] = (data[A_TERM_CREDITS] +
                                    section.student_credits)
        elif is_b_term(section.summer_term):
            data[B_TERM] = True
            data[B_TERM_SECTIONS] = data[B_TERM_SECTIONS] + 1
            data[B_TERM_CREDITS] = (data[B_TERM_CREDITS] +
                                    section.student_credits)
        else:
            pass
    return data
Example #4
0
def _get_future_term_json(term, summer_term, summer_term_data=None):
    return_json = term.json_data()
    return_json["summer_term"] = summer_term
    url = "/" + str(term.year) + "," + term.quarter
    if len(summer_term) > 0:
        url = url + "," + summer_term.lower()

        if is_a_term(summer_term):
            return_json["credits"] = str(summer_term_data[FULL_TERM_CREDITS] +
                                         summer_term_data[A_TERM_CREDITS])

            section_count = (summer_term_data[FULL_TERM_SECTIONS] +
                             summer_term_data[A_TERM_SECTIONS])
            return_json["section_count"] = section_count
        elif is_b_term(summer_term):
            return_json["credits"] = str(summer_term_data[FULL_TERM_CREDITS] +
                                         summer_term_data[B_TERM_CREDITS])

            section_count = (summer_term_data[FULL_TERM_SECTIONS] +
                             summer_term_data[B_TERM_SECTIONS])
            return_json["section_count"] = section_count
        elif is_full_summer_term(summer_term):
            return_json["credits"] = str(summer_term_data[FULL_TERM_CREDITS])
            return_json["section_count"] = summer_term_data[FULL_TERM_SECTIONS]
    else:
        return_json["credits"] = str(term.credits)
        return_json["section_count"] = term.section_count

    return_json["url"] = url
    return return_json
Example #5
0
 def test_is_summer_term(self):
     self.assertTrue(is_a_term("A-term"))
     self.assertTrue(is_b_term("B-term"))
     self.assertTrue(is_half_summer_term("A-term"))
     self.assertTrue(is_half_summer_term("B-term"))
     self.assertFalse(is_half_summer_term("Full-term"))
     self.assertTrue(is_full_summer_term("Full-term"))
     self.assertTrue(is_same_summer_term("A-term", "a-term"))
     self.assertFalse(is_same_summer_term("A-term", "Full-term"))
Example #6
0
def filter_schedule_sections_by_summer_term(schedule, summer_term):
    """
    Filter the schedule sections by the give summer_term.
    """
    if (has_summer_quarter_section(schedule) and
            is_half_summer_term(summer_term)):
        filtered_sections = []
        for section in schedule.sections:
            if (is_full_summer_term(section.summer_term) or
                    is_same_summer_term(section.summer_term, summer_term)):
                filtered_sections.append(section)
        schedule.sections = filtered_sections