async def add_new_club(cur, request): await request.post() utils.validate_request(request) try: input_list = [ request.POST['name'], request.POST['league'], request.POST['foundation'], request.POST['city'], request.POST['budget'] ] except KeyError: raise web.HTTPBadRequest() cur.callproc("CreateClub", input_list) return web.json_response({})
async def add_match(cur, request): await request.post() utils.validate_request(request) try: input_list = [ request.POST['club1'], request.POST['club2'], request.POST['seasonYear'], request.POST['round'], request.POST['refereeName'], request.POST['refereeSurname'], request.POST['stadium'], request.POST['date'] ] except KeyError: raise web.HTTPBadRequest() cur.callproc("CreateGame", input_list) return web.json_response({})
async def add_player(cur, request): await request.post() utils.validate_request(request) try: input_dict = { 'name': request.POST['name'], 'surname': request.POST['surname'], 'dateOfBirth': request.POST['dateOfBirth'], 'nationality': request.POST['nationality'], 'playingPosition': request.POST['playingPosition'] } except KeyError: raise web.HTTPBadRequest() await insert_into(cur, "Footballer", input_dict) return web.json_response({})
async def add_referee(cur, request): await request.post() utils.validate_request(request) try: input_dict = { 'name': request.POST['name'], 'surname': request.POST['surname'], 'dateOfBirth': request.POST['dateOfBirth'], 'nationality': request.POST['nationality'], 'category': request.POST['category'] } except KeyError: raise web.HTTPBadRequest() await insert_into(cur, "Referee", input_dict) return web.json_response({})
async def update_player_stats(cur, request): await request.post() utils.validate_request(request) p = request.POST try: input_list = [ p['cName'], p['date'], p['pName'], p['pSurname'], p['goals'], p['reds'], p['yellows'], p['passes'], p['assists'], p['owngoals'] ] except KeyError: raise web.HTTPBadRequest() logging.info(input_list) cur.callproc("UpdateStatisticsOfFootballer", input_list) result = [r.fetchall() for r in cur.stored_results()] logging.info("UPDATE: " + str(result)) return web.json_response({})