Moving and naming SQL statements
This commit is contained in:
parent
ec7ff3e3e1
commit
4d04ce697f
@ -37,7 +37,7 @@ def convenorAddClubResult():
|
||||
_club = request.form['clubName']
|
||||
club_lookup = "SELECT club FROM _clubTeams WHERE club='" + _club + "' GROUP BY club"
|
||||
club_create = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', 'A')"
|
||||
|
||||
|
||||
# validate that this data has been entered
|
||||
if _club and request.method == 'POST':
|
||||
clubExist = sql_read(club_lookup)
|
||||
@ -51,8 +51,8 @@ def convenorAddClubResult():
|
||||
|
||||
@routes.route('/convenor/teamAdd')
|
||||
def convenorAddTeam():
|
||||
sql = "SELECT club FROM _clubTeams GROUP BY club ORDER BY club"
|
||||
clubs = sql_read(sql)
|
||||
clubs_query = "SELECT club FROM _clubTeams GROUP BY club ORDER BY club"
|
||||
clubs = sql_read(clubs_query)
|
||||
form = addTeamForm()
|
||||
return render_template('_convenorTeamAdd.html', data=clubs, form=form)
|
||||
|
||||
@ -61,14 +61,15 @@ def convenorAddTeamResult():
|
||||
try:
|
||||
_club = request.form['clubName']
|
||||
_team = request.form['teamName']
|
||||
clubTeam_lookup = "SELECT club, team FROM _clubTeams WHERE club='" + _club + "' AND team='" + _team + "'"
|
||||
clubTeam_create = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', '" + _team + "')"
|
||||
if _club and _team and request.method == 'POST':
|
||||
sql = "SELECT club, team FROM _clubTeams WHERE club='" + _club + "' AND team='" + _team + "'"
|
||||
teamExist = sql_read(sql)
|
||||
sql =
|
||||
teamExist = sql_read(clubTeam_lookup)
|
||||
if teamExist:
|
||||
return 'Team already exists in the database'
|
||||
else:
|
||||
sql2 = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', '" + _team + "')"
|
||||
sql_write(sql2)
|
||||
sql_write(clubTeam_create)
|
||||
return render_template('_convenorTeamAddResults.html', club=_club, team=_team)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user