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
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
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"))
def summer_term_overlaped(request, given_section): """ @return true if: 1). this is not a summer quarter or 2). the given_summer_term is overlaped with the current summer term in the request """ current_summer_term = get_current_summer_term(request) if given_section is None or current_summer_term is None: return True return (given_section.is_same_summer_term(current_summer_term) or given_section.is_full_summer_term() and is_b_term(current_summer_term))
def is_half_summer_term(str): """ return True if the given str is A-term or B-term @return True if the given str is A-term or B-term """ return is_a_term(str) or is_b_term(str)
def _get_summer_term(term): if is_a_term(term["summer_term"]): return "A" if is_b_term(term["summer_term"]): return "B" return "F" # non-summer terms and full summer term