def addPage(): #Select all pro teams cursor = connection.cursor() cursor.execute("select * from Team where is_pro = 1;") results = cursor.fetchall() cursor.close() #Get players on those teams cursor = connection.cursor() cursor.execute( "select ID, Player, Role, PlayerPhoto from Teams_All_Players where PRO = 1;" ) teams_Players = cursor.fetchall() cursor.close() #Get all players cursor = connection.cursor() cursor.execute("select battletag from Player") allPlayers = cursor.fetchall() cursor.close() return render_template("addplayers.html", username=functions.getUsername(), allPlayers=allPlayers, teamTable=results, teamPlayers=teams_Players)
def players(): #Select all players cursor = connection.cursor() cursor.execute("select * from All_Players_ON_Teams;") results = cursor.fetchall() cursor.close() """Renders the myteams page.""" return render_template("players.html", username=functions.getUsername(), playerTable=results)
def myteams(): #Select all users teams cursor = connection.cursor() cursor.execute("select * from Team where is_pro = 0 AND OWNER = \'" + functions.getUsername() + "\';") results = cursor.fetchall() cursor.close() #Get players on those teams cursor = connection.cursor() cursor.execute("""select ID, Player, Role, PlayerPhoto from Teams_All_Players where PRO = 0 AND OWNER = \'""" + functions.getUsername() + "\';") teams_Players = cursor.fetchall() cursor.close() """Renders the myteams page.""" return render_template("myteam.html", username=functions.getUsername(), teamTable=results, teamPlayers=teams_Players)
def newPass(): oldPass = request.form['oldPass'] newPass = request.form['newPass'] #Check if old password is in database cursor = connection.cursor() cursor.execute("select password from Users where username = \'" + functions.getUsername() + "\';") passValidator = cursor.fetchall() cursor.close() print(passValidator) if len(passValidator) != 0: cursor = connection.cursor() cursor.execute("update Users set password=\'" + newPass + "\' where username = \'" + functions.getUsername() + "\';") connection.commit() cursor.close() return redirect('/success.html') return redirect('/invalid.html')
def heroes(): cursor = connection.cursor() cursor.execute("select * from Hero") hTable = cursor.fetchall() cursor.close() cursor = connection.cursor() cursor.execute( "select hero_name, ability_name, ability_desc from All_Hero_Info;") aTable = cursor.fetchall() cursor.close() """Renders the heroes page.""" return render_template("heroes.html", username=functions.getUsername(), heroTable=hTable, abilityTable=aTable)
def team(): #Select all pro teams cursor = connection.cursor() cursor.execute("select * from Team where is_pro = 1;") results = cursor.fetchall() cursor.close() #Get players on those teams cursor = connection.cursor() cursor.execute( "select ID, Player, Role, PlayerPhoto from Teams_All_Players where PRO = 1;" ) teams_Players = cursor.fetchall() cursor.close() """Renders the team page.""" return render_template("teams.html", username=functions.getUsername(), teamTable=results, teamPlayers=teams_Players)
def home(): cursor = connection.cursor() cursor.execute( "SELECT MAX(win_rate), city, mascot, logo, OWNER FROM Team_Win_Rate Group By city, mascot, logo, OWNER;" ) team = cursor.fetchall() cursor.close() #Find Player name with highest average elims and winrate between all heroes cursor = connection.cursor() cursor.execute( "SELECT MAX(score), battletag, player_avg_elims, overall_win_rate FROM Avg_Player_Stats Group by battletag, player_avg_elims, overall_win_rate;" ) player = cursor.fetchall() cursor.close() #Find the Hero with the highest popularity cursor = connection.cursor() cursor.execute( "SELECT MAX(hero_pick_rate), name, photo FROM Hero Group by name, photo;" ) hero = cursor.fetchall() cursor.close() for n in team: bestTeam = n for n in player: bestPlayer = n for n in hero: bestHero = n print(bestHero) return render_template("home.html", username=functions.getUsername(), bestTeam=team, bestPlayer=player, mostPopularHero=hero)
def edtTeam(): id = request.args.get('id') session['curr_team'] = id #Get all players cursor = connection.cursor() cursor.execute("select battletag from Player") allPlayers = cursor.fetchall() cursor.close() #Query up team info for teamID = ID cursor = connection.cursor() cursor.execute( "select ID, Team, Player, PlayerPhoto from Teams_All_Players where ID = " + id + ";") playerTable = cursor.fetchall() cursor.close() #Query up team info for teamID = ID cursor = connection.cursor() cursor.execute("select city, mascot from Team where ID = " + id) teamName = cursor.fetchall() cursor.close() if len(playerTable) == 0: return redirect("/addplayers.html") #Show players on team and allow editing of each player. print(teamName) tName = teamName[0][0] + " " + teamName[0][1] return render_template("editTeam.html", username=functions.getUsername(), allPlayers=allPlayers, playerTable=playerTable, teamname=tName)
def makeTeamName(): return render_template("createteams.html", username=functions.getUsername())
def signupPage(): """Renders the signup page.""" return render_template("signup.html", username=functions.getUsername())
def login(): """Renders the login page.""" return render_template("login.html", username=functions.getUsername())
def errMsg(): return render_template('/invalid.html', username=functions.getUsername())
def successMsg(): return render_template('/success.html', username=functions.getUsername())
def accountInfo(): return render_template("account.html", username=functions.getUsername())
def play_main_page(): """Renders the play page.""" return render_template("play.html", username=functions.getUsername())