def GET(self, request): """ GET returns 200 with the student account balances of the current user """ timer = Timer() logger = logging.getLogger(__name__) profile = get_profile_of_current_user() if profile is None: log_data_not_found_response(logger, timer) return data_not_found() log_success_response(logger, timer) response = profile.json_data() response['campus'] = get_base_campus(request) enrollment = get_current_quarter_enrollment(request) if enrollment is not None: response['is_grad_student'] = is_grad_student() response['class_level'] = enrollment.class_level if len(enrollment.majors) > 0: response['majors'] = [] for major in enrollment.majors: response['majors'].append(major.json_data()) if len(enrollment.minors) > 0: response['minors'] = [] for minor in enrollment.minors: response['minors'].append(minor.json_data()) logger.debug(response) return HttpResponse(json.dumps(response))
def GET(self, request): """ GET returns 200 with the student account balances of the current user """ timer = Timer() try: profile = get_profile_of_current_user() response = profile.json_data() response['campus'] = get_base_campus(request) response['is_grad_student'] = is_grad_student() try: enrollment = get_current_quarter_enrollment(request) response['class_level'] = enrollment.class_level if len(enrollment.majors) > 0: response['majors'] = [] for major in enrollment.majors: response['majors'].append(major.json_data()) if len(enrollment.minors) > 0: response['minors'] = [] for minor in enrollment.minors: response['minors'].append(minor.json_data()) except Exception: pass log_success_response(logger, timer) return HttpResponse(json.dumps(response)) except Exception: return handle_exception(logger, timer, traceback)
def GET(self, request): """ GET returns 200 with the student account balances of the current user """ timer = Timer() try: profile = get_profile_of_current_user() response = profile.json_data() response['display_name'] = get_display_name_of_current_user() response['campus'] = get_base_campus(request) response['is_grad_student'] = is_grad_student() try: enrollment = get_current_quarter_enrollment(request) response['class_level'] = enrollment.class_level if len(enrollment.majors) > 0: response['majors'] = [] for major in enrollment.majors: response['majors'].append(major.json_data()) if len(enrollment.minors) > 0: response['minors'] = [] for minor in enrollment.minors: response['minors'].append(minor.json_data()) except Exception: pass log_success_response(logger, timer) return HttpResponse(json.dumps(response)) except Exception: return handle_exception(logger, timer, traceback)
def log_session(netid, session_key, request): if session_key is None: session_key = '' session_hash = hashlib.md5(session_key).hexdigest() log_entry = {'netid': netid, 'session_key': session_hash, 'class_level': None, 'is_grad': None, 'campus': None} try: level = get_current_quarter_enrollment(request).class_level log_entry['class_level'] = level is_mobile = request.is_mobile or request.is_tablet log_entry['is_mobile'] = bool(is_mobile) except AttributeError: pass log_entry['is_grad'] = is_grad_student() log_entry['is_ugrad'] = is_undergrad_student() log_entry['campus'] = get_base_campus(request) logger.info(json.dumps(log_entry))
def log_session(netid, session_key, request): if session_key is None: session_key = '' session_hash = hashlib.md5(session_key).hexdigest() log_entry = { 'netid': netid, 'session_key': session_hash, 'class_level': None, 'is_grad': None, 'is_ugrad': None, 'is_student': None, 'campus': None } try: level = get_current_quarter_enrollment(request).class_level log_entry['class_level'] = level is_mobile = request.is_mobile or request.is_tablet log_entry['is_mobile'] = bool(is_mobile) except Exception: pass try: log_entry['is_grad'] = is_grad_student() except Exception: pass try: log_entry['is_ugrad'] = is_undergrad_student() except Exception: pass try: log_entry['is_student'] = is_student() except Exception: pass try: log_entry['campus'] = get_base_campus(request) except Exception: pass logger.info(json.dumps(log_entry))
def get_links_for_category(search_category_id, request): return _get_links_by_category_and_campus(search_category_id, get_base_campus(request), get_all_affiliations(request))