def get_current_quarter_enrollment(request): regid = get_regid_of_current_user() timer = Timer() id = "%s %s" % ('get enrollment by regid', regid) try: return get_enrollment_by_regid_and_term(regid, get_current_quarter(request)) finally: log_resp_time(logger, id, timer)
def GET(self, request, year, quarter): timer = Timer() try: no_myplan_access = during_myplan_peak_load( get_comparison_datetime(request), request) if no_myplan_access: log_msg(logger, timer, "No MyPlan access during their peak load, abort!") return HttpResponse('[]') plan = get_plan(regid=get_regid_of_current_user(), year=year, quarter=quarter.lower(), terms=1) base_json = plan.json_data() has_ready_courses = False has_unready_courses = False ready_count = 0 unready_count = 0 has_sections = False for course in base_json["terms"][0]["courses"]: if course["registrations_available"]: has_ready_courses = True ready_count = ready_count + 1 for section in course["sections"]: has_sections = True curriculum = course["curriculum_abbr"].upper() section_id = section["section_id"].upper() label = "%s,%s,%s,%s/%s" % (year, quarter.lower(), curriculum, course["course_number"], section_id ) sws_section = get_section_by_label(label) section["section_data"] = sws_section.json_data() else: if len(course["sections"]): has_sections = True has_unready_courses = True unready_count = unready_count + 1 base_json["terms"][0]["has_ready_courses"] = has_ready_courses base_json["terms"][0]["has_unready_courses"] = has_unready_courses base_json["terms"][0]["ready_count"] = ready_count base_json["terms"][0]["unready_count"] = unready_count base_json["terms"][0]["has_sections"] = has_sections log_success_response(logger, timer) return HttpResponse(json.dumps(base_json)) except Exception: log_err(logger, timer, traceback.format_exc()) return HttpResponse('[]')
def get_current_quarter_enrollment(request): regid = get_regid_of_current_user() timer = Timer() id = "%s %s" % ("get enrollment by regid", regid) try: return get_enrollment_by_regid_and_term(regid, get_current_quarter(request)) except Exception: log_exception(logger, id, traceback.format_exc()) finally: log_resp_time(logger, id, timer) return None
def GET(self, request, year, quarter): timer = Timer() try: no_myplan_access = during_myplan_peak_load( get_comparison_datetime(request), request) if no_myplan_access: log_msg(logger, timer, "No MyPlan access during their peak load, abort!") return HttpResponse('[]') plan = get_plan(regid=get_regid_of_current_user(), year=year, quarter=quarter.lower(), terms=1) base_json = plan.json_data() has_ready_courses = False has_unready_courses = False ready_count = 0 unready_count = 0 has_sections = False for course in base_json["terms"][0]["courses"]: if course["registrations_available"]: has_ready_courses = True ready_count = ready_count + 1 for section in course["sections"]: has_sections = True curriculum = course["curriculum_abbr"].upper() section_id = section["section_id"].upper() label = "%s,%s,%s,%s/%s" % (year, quarter.lower( ), curriculum, course["course_number"], section_id) sws_section = get_section_by_label(label) section["section_data"] = sws_section.json_data() else: if len(course["sections"]): has_sections = True has_unready_courses = True unready_count = unready_count + 1 base_json["terms"][0]["has_ready_courses"] = has_ready_courses base_json["terms"][0]["has_unready_courses"] = has_unready_courses base_json["terms"][0]["ready_count"] = ready_count base_json["terms"][0]["unready_count"] = unready_count base_json["terms"][0]["has_sections"] = has_sections log_success_response(logger, timer) return HttpResponse(json.dumps(base_json)) except Exception: log_err(logger, timer, traceback.format_exc()) return HttpResponse('[]')
def get_canvas_enrolled_courses(): """ Returns calendar information for the current term. Raises: DataFailureException """ timer = Timer() try: regid = get_regid_of_current_user() return get_indexed_data_for_regid(regid) except AttributeError: # If course is not in canvas, skip return [] finally: log_resp_time(logger, 'get_canvas_enrolled_courses', timer)
def GET(self, request): try: quarter = get_current_quarter(request) plan = get_plan(regid=get_regid_of_current_user(), year=quarter.year, quarter=quarter.quarter, terms=4) return HttpResponse(json.dumps(plan.json_data())) except Exception as ex: # Log the error, but don't have the front end complain print ex logger.error(ex) return HttpResponse('[]')
def get_profile_of_current_user(): """ Return restclients.models.sws.SwsPerson object """ regid = get_regid_of_current_user() timer = Timer() id = "%s %s" % ('get sws.person by regid', regid) try: return get_person_by_regid(regid) finally: log_resp_time(logger, id, timer)
def get_canvas_enrolled_courses(): """ Returns calendar information for the current term. """ timer = Timer() try: regid = get_regid_of_current_user() return get_indexed_data_for_regid(regid) except AttributeError: # If course is not in canvas, skip pass except Exception as ex: log_exception(logger, "get_canvas_enrolled_courses", traceback.format_exc()) finally: log_resp_time(logger, "get_canvas_enrolled_courses", timer) return []
def get_profile_of_current_user(): """ Return restclients.models.sws.SwsPerson object """ regid = get_regid_of_current_user() timer = Timer() id = "%s %s" % ('get sws.person by regid', regid) try: return get_person_by_regid(regid) except Exception: log_exception(logger, id, traceback.format_exc()) finally: log_resp_time(logger, id, timer) return None
def get_schedule_by_term(request, term): """ Return the actively enrolled sections for the current user in the given term/quarter """ # 2016 approach for MUWM-3390/3391 # If we're in the EFS period, include the sections. Otherwise, # exclude them. schedule = _get_schedule(get_regid_of_current_user(), term) comparison_date = get_comparison_date(request) included_sections = [] for section in schedule.sections: if EARLY_FALL_START != section.institute_name: included_sections.append(section) else: end_date = section.end_date if end_date >= comparison_date: included_sections.append(section) schedule.sections = included_sections return schedule
def get_account_balances_for_current_user(): return _get_account_balances_by_regid(get_regid_of_current_user())
def get_grad_petition_for_current_user(): """ returns json data of grad degree requests for the current user """ return get_petition_by_regid(get_regid_of_current_user())
def get_grad_committee_for_current_user(): """ returns json data of grad degree requests for the current user """ return get_committee_by_regid(get_regid_of_current_user())
def get_colors_by_schedule(schedule): return get_colors_by_regid_and_schedule( get_regid_of_current_user(), schedule)
def get_colors_by_schedule(schedule): return get_colors_by_regid_and_schedule(get_regid_of_current_user(), schedule)
def get_notices_for_current_user(): notices = _get_notices_by_regid(get_regid_of_current_user()) if notices is None: return [] return _get_user_notices(notices)
def get_notices_for_current_user(): notices = _get_notices_by_regid(get_regid_of_current_user()) return _get_user_notices(notices)
def get_schedule_by_term(term): """ Return the actively enrolled sections for the current user in the given term/quarter """ return _get_schedule(get_regid_of_current_user(), term)