REmoved search
This commit is contained in:
parent
754fc69331
commit
7f9f00b9c4
@ -1,167 +0,0 @@
|
||||
#import MySQLdb
|
||||
import pymysql
|
||||
from dbWrite import sql_read, sql_read_static
|
||||
from flask import render_template, request
|
||||
from forms import searchForm, playerRecordsForm, teamRecordsForm, clubPlayingRecordsForm
|
||||
from . import routes
|
||||
from tables import Results, playerResults, teamResults, clubPlayingRecord
|
||||
import datetime
|
||||
from datetime import date
|
||||
|
||||
|
||||
@routes.route('/search')
|
||||
def search():
|
||||
sql = "SELECT hockeyClub FROM mensHockeyClubs ORDER BY hockeyClub"
|
||||
sql2 = "SELECT nextClub, oppoLogo FROM hkfcDAdminSettings"
|
||||
clubs = sql_read_static(sql)
|
||||
settings = sql_read_static(sql2)
|
||||
form = searchForm()
|
||||
form.clubName.choices = [(name['hockeyClub'], name['hockeyClub']) for name in clubs]
|
||||
clubLogo = settings[0]['oppoLogo']
|
||||
return render_template('_search.html', data=clubs, selectedClubLogo=clubLogo, form=form)
|
||||
|
||||
@routes.route('/searchTeam', methods=['POST'])
|
||||
def searchTeam():
|
||||
_season = request.form['season']
|
||||
_club = request.form['clubName']
|
||||
_team = request.form['teamName']
|
||||
_startDate = request.form['startDate']
|
||||
_endDate = request.form['endDate']
|
||||
print(request.form)
|
||||
# validate that this data has been entered
|
||||
if _club and _team and request.method == 'POST':
|
||||
sql = "SELECT * FROM _mensResults WHERE (matchDate BETWEEN '" + _startDate + "' AND '" + _endDate + "') AND ((matchHomeClub='" + _club + "' AND matchHomeTeam='" + _team + "') OR (matchAwayClub='" + _club + "' AND matchAwayTeam='" + _team + "')) ORDER BY matchDate"
|
||||
rows = sql_read(sql)
|
||||
table = Results(rows)
|
||||
table.border = True
|
||||
table.classes = ['table-striped', 'table-condensed', 'table-hover']
|
||||
return render_template('_searchResults.html', table=table)
|
||||
else:
|
||||
return 'Invalid search data entered'
|
||||
|
||||
|
||||
@routes.route('/playerRecords')
|
||||
def playerRecords():
|
||||
sql = "SELECT hockeyClub FROM mensHockeyClubs ORDER BY hockeyClub"
|
||||
sql2 = "SELECT nextClub, oppoLogo FROM hkfcDAdminSettings"
|
||||
clubs = sql_read_static(sql)
|
||||
settings = sql_read_static(sql2)
|
||||
form = playerRecordsForm()
|
||||
form.clubName.choices = [(name['hockeyClub'], name['hockeyClub']) for name in clubs]
|
||||
clubLogo = settings[0]['oppoLogo']
|
||||
return render_template('_playerRecords.html', data=clubs, selectedClubLogo=clubLogo, form=form)
|
||||
|
||||
@routes.route('/playerRecordSearch', methods=['POST'])
|
||||
def playerRecordSearchResults():
|
||||
columnName = {}
|
||||
matchNumbersList = []
|
||||
_season = request.form['season']
|
||||
_club = request.form['clubName']
|
||||
_team = request.form['teamName']
|
||||
lookup_table = _club.lower() + _team
|
||||
if _club and _team and request.method == 'POST':
|
||||
sql = "SELECT * FROM _" + _season + "_" + lookup_table + " ORDER BY playerNumber"
|
||||
sql2 = "SHOW COLUMNS FROM _" + _season + "_" + lookup_table + ""
|
||||
sql3 = "SELECT matchNumber, matchHomeClub, matchHomeTeam, matchAwayClub, matchAwayTeam FROM _" + _season + "_mensResults WHERE (matchHomeClub='" + _club + "' AND matchHomeTeam='" + _team + "') OR (matchAwayClub='" + _club + "' AND matchAwayTeam='" + _team + "')"
|
||||
rows = sql_read_static(sql)
|
||||
columns = sql_read_static(sql2)
|
||||
matches = sql_read_static(sql3)
|
||||
for match in matches:
|
||||
matchNumbersList.append(str(match['matchNumber']))
|
||||
if match['matchHomeClub'] == _club:
|
||||
columnName[str(match['matchNumber'])] = match['matchAwayClub'] + " " + match['matchAwayTeam']
|
||||
else:
|
||||
columnName[str(match['matchNumber'])] = match['matchHomeClub'] + " " + match['matchHomeTeam']
|
||||
return render_template('_playerRecordResults.html', rows=rows, columns=columns, matches=columnName, matchesList=matchNumbersList)
|
||||
else:
|
||||
return 'Invalid search data entered'
|
||||
|
||||
|
||||
@routes.route('/teamRecords')
|
||||
def teamRecords():
|
||||
sql = "SELECT hockeyClub FROM mensHockeyClubs ORDER BY hockeyClub"
|
||||
sql2 = "SELECT nextClub, oppoLogo FROM hkfcDAdminSettings"
|
||||
clubs = sql_read_static(sql)
|
||||
settings = sql_read_static(sql2)
|
||||
form = teamRecordsForm()
|
||||
form.clubName.choices = [(name['hockeyClub'], name['hockeyClub']) for name in clubs]
|
||||
clubLogo = settings[0]['oppoLogo']
|
||||
return render_template('_teamRecords.html', data=clubs, selectedClubLogo=clubLogo, form=form)
|
||||
|
||||
@routes.route('/teamRecordSearch', methods=['POST'])
|
||||
def teamRecordResults():
|
||||
_season = request.form['season']
|
||||
_club = request.form['clubName']
|
||||
_team = request.form['teamName']
|
||||
lookup_table = _club.lower() + _team
|
||||
if _club and _team and request.method == 'POST':
|
||||
sql = "SELECT * FROM _" + _season + "_record_" + lookup_table + " ORDER BY opposition"
|
||||
print(sql)
|
||||
rows = sql_read_static(sql)
|
||||
table = teamResults(rows)
|
||||
table.border = True
|
||||
table.classes = ['table-striped', 'table-condensed', 'table-hover']
|
||||
return render_template('_teamRecordResults.html', table=table)
|
||||
else:
|
||||
return 'Invalid search data entered'
|
||||
|
||||
|
||||
@routes.route('/clubPlayingRecords')
|
||||
def clubPlayingRecords():
|
||||
sql = "SELECT hockeyClub FROM mensHockeyClubs ORDER BY hockeyClub"
|
||||
sql2 = "SELECT nextClub, oppoLogo FROM hkfcDAdminSettings"
|
||||
clubs = sql_read_static(sql)
|
||||
settings = sql_read_static(sql2)
|
||||
form = clubPlayingRecordsForm()
|
||||
form.clubName.choices = [(name['hockeyClub'], name['hockeyClub']) for name in clubs]
|
||||
clubLogo = settings[0]['oppoLogo']
|
||||
return render_template('_clubPlayingRecords.html', data=clubs, selectedClubLogo=clubLogo, form=form)
|
||||
|
||||
@routes.route('/clubPlayingRecordSearch', methods=['POST'])
|
||||
def clubPlayingRecordRearchResults():
|
||||
_season = request.form['season']
|
||||
_club = request.form['clubName']
|
||||
if _club and request.method == 'POST':
|
||||
sql = "SELECT * FROM _" + _season + "_playerRecord_" + _club.lower() + " ORDER BY playerNumber"
|
||||
sql2 = "SHOW COLUMNS FROM _" + _season + "_playerRecord_" + _club.lower() + ""
|
||||
rows = sql_read_static(sql)
|
||||
columns = sql_read_static(sql2)
|
||||
return render_template('_clubPlayingRecordResults.html', rows=rows, columns=columns)
|
||||
else:
|
||||
return 'Invalid search data entered'
|
||||
|
||||
|
||||
@routes.route('/playerCheck')
|
||||
def playerCheck():
|
||||
sql = "SELECT hockeyClub FROM mensHockeyClubs ORDER BY hockeyClub"
|
||||
sql2 = "SELECT nextClub, oppoLogo FROM hkfcDAdminSettings"
|
||||
clubs = sql_read_static(sql)
|
||||
settings = sql_read_static(sql2)
|
||||
form = clubPlayingRecordsForm()
|
||||
form.clubName.choices = [(name['hockeyClub'], name['hockeyClub']) for name in clubs]
|
||||
clubLogo = settings[0]['oppoLogo']
|
||||
return render_template('_playerCheck.html', data=clubs, selectedClubLogo=clubLogo, form=form)
|
||||
|
||||
@routes.route('/playerCheckResults', methods=['POST'])
|
||||
def playerCheckResults():
|
||||
_season = request.form['season']
|
||||
_club = request.form['clubName']
|
||||
players = []
|
||||
if _club and request.method == 'POST':
|
||||
sql = "SELECT * FROM _playerRecord_" + _club.lower() + " ORDER BY playerNumber"
|
||||
sql2 = "SHOW COLUMNS FROM _playerRecord_" + _club.lower() + ""
|
||||
rows = sql_read_static(sql)
|
||||
columns = sql_read_static(sql2)
|
||||
for row in rows:
|
||||
has_played = 0
|
||||
for column in columns:
|
||||
if column['Field'].startswith("appearances"):
|
||||
if row[column['Field']] > 0:
|
||||
if has_played == 1:
|
||||
players.append(row)
|
||||
break
|
||||
else:
|
||||
has_played = 1
|
||||
return render_template('_playerCheckResults.html', rows=players, columns=columns)
|
||||
else:
|
||||
return 'Invalid search data entered'
|
||||
Loading…
Reference in New Issue
Block a user