def courseGET(courseNum): if not courseNum: # return all courseNum return json_response( list(course['courses'] for course in course_bucket.n1ql_query( 'select * from courses'))) return json_response(course_bucket.get(courseNum, quiet=True).value)
def offeringGET(quarter, courseNum, sectionId): if not sectionId: if not courseNum: if not quarter: return json_response(all_offerings()) return get_for_quarter(quarter) return json_response( get_course_sections_for_quarter(quarter, courseNum)) return json_response(get_single_offering(quarter, courseNum, sectionId))
def quarterGet(quarterId): all_nested = offering_bucket.get(quarterId, quiet=True).value if not all_nested: return json_response(None) flat = [] for values in ((list(value.values()) for value in all_nested.values())): flat.extend(values) return json_response(flat)
def userDELETE(username): del_res = user_bucket.remove(username) # type: OperationResult del_all_scheds_for(username) return json_response(del_res.success)
def userGET(username): if not username: # return all users return json_response(get_all_users()) return json_response(get_user(username)) # type: ValueResult
def recommend_main(userId): return json_response(recommend_courses_for(userId))
def students(): return json_response(users.get_students())
def professors(): return json_response(users.get_professors())
def search_query(): return json_response(search.run_search(**(request.get_json())))
def scheduleLookup(studentId, quarterId): try: return json_response(schedules.get_user_schedule(studentId, quarterId)) except Exception as e: print("Lookup exception:", type(e), e) return make_response(str(e), 500)