def parse_full_report(left_off): game_report_url = build_game_report_url(left_off) home_roster_url = build_home_roster_url(left_off) visitor_roster_url = build_visitor_roster_url(left_off) game_json = parse_game(game_report_url) home_players = parse_roster(home_roster_url) visitor_players = parse_roster(visitor_roster_url) game_json['home_players'] = home_players game_json['visitor_players'] = visitor_players return game_json
def POST(self,class_id,student_id=""): authenticate() if student_id: #edit one student params = web.input() status = params.get('status') teach_assn = params.get('teach_assn') if status and teach_assn: q = """UPDATE CLASSES_STUDENTS SET status=$status,teach_assn=$teach_assn WHERE class_id=$class_id AND student_id=$student_id""" elif teach_assn: q = """UPDATE CLASSES_STUDENTS SET teach_assn=$teach_assn WHERE class_id=$class_id AND student_id=$student_id""" else: q = """UPDATE CLASSES_STUDENTS SET status=$status WHERE class_id=$class_id AND student_id=$student_id""" vars = {'class_id':class_id,'student_id':student_id, 'status':status,'teach_assn':teach_assn} db.query(q,vars) referer = web.ctx.env.get('HTTP_REFERER') if referer: raise web.seeother(referer) raise web.seeother('/classes/%s/students/%s'%(class_id,student_id)) else: #upload roster params = web.input(roster={}) file = params['roster'] lines = file.file.readlines() lines.replace('\r','') try: data = parse_roster(file.file) except KeyError,err: error = "there was a problem parsing the given csv file. The column, '%s' was not present"%str(err) raise web.seeother('/classes/%s?error=%s'%(class_id,error)) q0="""SELECT student_id FROM STUDENTS WHERE student_id=$student_id""" q1="""INSERT INTO STUDENTS VALUES($student_id, $first_name, $last_name, $dec, $parent_name, Null, Null, $grade, $phone_number, $r_score_in, $w_score_in, Null,Null,Null)""" #WHERE NOT EXISTS (SELECT * FROM STUDENTS WHERE student_id=$student_id)""" q2="""SELECT * FROM CLASSES_STUDENTS WHERE class_id=$class_id AND student_id=$student_id""" q3="""INSERT INTO CLASSES_STUDENTS VALUES($class_id,$student_id, $status,"GenEd")""" for row in data: row['class_id'] = class_id check = db.query(q0,row) if not check: db.query(q1,row) check = db.query(q2,row) if not check :db.query(q3,row) referer = web.ctx.env.get('HTTP_REFERER') if referer: raise web.seeother(referer) raise web.seeother('/classes/%s'%class_id)