Reducing the files down to what is required

This commit is contained in:
jenkins-x-bot 2020-09-12 21:38:52 +08:00
parent 456f3b58eb
commit 8d6123db47
57 changed files with 48 additions and 3468 deletions

View File

@ -1,165 +0,0 @@
#import MySQLdb
import pymysql
import os
import json
# These environment variables are configured in app.yaml.
CLOUDSQL_CONNECTION_NAME = "hk-hockey:asia-east2:hk-hockey-sql"
CLOUDSQL_USER = "root"
CLOUDSQL_WRITE_USER = "hockeyWrite"
CLOUDSQL_READ_USER = "hockeyRead"
CLOUDSQL_PASSWORD = "P8P1YopMlwg8TxhE"
CLOUDSQL_WRITE_PASSWORD = "1URYcxXXlQ6xOWgj"
CLOUDSQL_READ_PASSWORD = "o4GWrbbkBKy3oR6u"
CLOUDSQL_DATABASE = "2019_hockeyResults"
LOCAL_DATABASE = "hockeyResults2019"
CLOUDSQL_DATABASE_STATIC = "hockeyResults"
CLOUDSQL_CHARSET = "utf8"
def write_cloudsql():
# When deployed to App Engine, the `SERVER_SOFTWARE` environment variable
# will be set to 'Google App Engine/version'.
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
# will work if you're running a local MySQL server or using the Cloud SQL
# proxy, for example:
#
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host='db.ipa.champion', user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=LOCAL_DATABASE, charset=CLOUDSQL_CHARSET)
return db
def write_cloudsql_static():
# When deployed to App Engine, the `SERVER_SOFTWARE` environment variable
# will be set to 'Google App Engine/version'.
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
# will work if you're running a local MySQL server or using the Cloud SQL
# proxy, for example:
#
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host='db.ipa.champion', user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
return db
def read_cloudsql():
# When deployed to App Engine, the `SERVER_SOFTWARE` environment variable
# will be set to 'Google App Engine/version'.
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
# will work if you're running a local MySQL server or using the Cloud SQL
# proxy, for example:
#
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host='db.ipa.champion', user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=LOCAL_DATABASE, charset=CLOUDSQL_CHARSET)
return db
def read_cloudsql_static():
# When deployed to App Engine, the `SERVER_SOFTWARE` environment variable
# will be set to 'Google App Engine/version'.
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
# will work if you're running a local MySQL server or using the Cloud SQL
# proxy, for example:
#
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host='db.ipa.champion', user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
return db
def sql_write(sql_cmd):
try:
db = write_cloudsql()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
db.commit()
except Exception as e:
print(e)
finally:
cursor.close()
db.close()
return db
def sql_write_static(sql_cmd):
try:
db = write_cloudsql_static()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
db.commit()
except Exception as e:
print(e)
finally:
cursor.close()
db.close()
return db
def sql_read(sql_cmd):
try:
db = read_cloudsql()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
rows = cursor.fetchall()
except Exception as e:
print(e)
rows = ''
finally:
cursor.close()
db.close()
return rows
def sql_read_static(sql_cmd):
try:
db = read_cloudsql_static()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
rows = cursor.fetchall()
except Exception as e:
print(e)
rows = ''
finally:
cursor.close()
db.close()
return rows

12
main.py
View File

@ -27,6 +27,18 @@ def get_namespaces():
data = json.loads(output)
return data
def get_deployments(namespace):
command = "/usr/local/bin/kubectl -n " + namespace + " get deploy -ojson"
info(f"Running command: {command}")
try:
output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
except CalledProcessError as err:
error(err.output.decode("utf-8"))
raise err
info(f"Output from command:\n{output}")
data = json.loads(output)
return data
@app.route('/', methods=['GET', 'POST'])
def namespacesForm():
form = deploySelectForm()

View File

@ -1,39 +0,0 @@
#import MySQLdb
import pymysql
import os
import json
from app import app
#from dbWrite import read_cloudsql, sql_read, write_cloudsql, sql_write, read_cloudsql_static, sql_read_static, write_cloudsql_static, sql_write_static
from dbWrite import sql_read_static
def mySettings(arg):
sql2 = "SELECT nextClub, nextTeam, nextDate, oppoLogo, hkfcLogo, currMotM, currDotD, nextFixture, prevFixture FROM hkfcDAdminSettings"
settingsInfo = sql_read_static(sql2)
nextClub = settingsInfo[0]['nextClub']
nextTeam = settingsInfo[0]['nextTeam']
nextDate = settingsInfo[0]['nextDate']
hkfcLogo = settingsInfo[0]['hkfcLogo']
oppoLogo = settingsInfo[0]['oppoLogo']
currMotM = settingsInfo[0]['currMotM']
currDotD = settingsInfo[0]['currDotD']
fixtureNumber = settingsInfo[0]['nextFixture']
prevFixture = settingsInfo[0]['prevFixture']
if arg == 'club':
return nextClub
elif arg == 'team':
return nextTeam
elif arg == 'date':
return nextDate
elif arg == 'motm':
return currMotM
elif arg == 'dotd':
return currDotD
elif arg == 'fixture':
return fixtureNumber
elif arg == 'prevFixture':
return prevFixture
else:
return settingsInfo

View File

@ -1,8 +0,0 @@
from flask import Blueprint
routes = Blueprint('routes', __name__)
from .dashboard import *
from ._search import *
from ._matches import *
from ._hkfcD_motm import *
from ._convenor import *

View File

@ -1,240 +0,0 @@
#import MySQLdb
import pymysql
import os
from flask import render_template, request
from flask_basicauth import BasicAuth
from app import app
from dbWrite import sql_read, sql_write, sql_read_static, sql_write_static
from forms import addPlayerForm, addTeamForm, addClubForm, playerDbCreateForm, squadListForm
from tables import clubList, convenorSquadListTable, convenorFixtureList
from . import routes
import json
BASIC_AUTH_USERNAME = 'admin'
BASIC_AUTH_PASSWORD = '7GcGJTRs1DoCCNYCTGK2yeXmTGxtxonQ'
basic_auth = BasicAuth(app)
@routes.route('/convenor/clubList')
@basic_auth.required
def convenorListClub():
sql = "SELECT club, team, league from _clubTeams ORDER BY club, team"
rows = sql_read(sql)
print(rows)
table = clubList(rows)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('_convenorClubList.html', table=table)
@routes.route('/convenor/clubAdd')
@basic_auth.required
def convenorAddClub():
form = addClubForm()
return render_template('_convenorClubAdd.html', form = form)
@routes.route('/convenor/clubAddResult', methods=['POST'])
@basic_auth.required
def convenorAddClubResult():
try:
_club = request.form['clubName']
# validate that this data has been entered
if _club and request.method == 'POST':
sql = "SELECT club FROM _clubTeams WHERE club='" + _club + "' GROUP BY club"
clubExist = sql_read(sql)
if clubExist:
return 'Club already exists - try adding a team instead'
else:
sql2 = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', 'A')"
sql_write(sql2)
return render_template('_convenorClubAddResults.html', data=_club)
except Exception as e:
print(e)
@routes.route('/convenor/teamAdd')
@basic_auth.required
def convenorAddTeam():
sql = "SELECT club FROM _clubTeams GROUP BY club ORDER BY club"
clubs = sql_read(sql)
form = addTeamForm()
return render_template('_convenorTeamAdd.html', data=clubs, form=form)
@routes.route('/convenor/teamAddResult', methods=['POST'])
@basic_auth.required
def convenorAddTeamResult():
try:
_club = request.form['clubName']
_team = request.form['teamName']
if _club and _team and request.method == 'POST':
sql = "SELECT club, team FROM _clubTeams WHERE club='" + _club + "' AND team='" + _team + "'"
teamExist = sql_read(sql)
if teamExist:
return 'Team already exists in the database'
else:
sql2 = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', '" + _team + "')"
sql_write(sql2)
return render_template('_convenorTeamAddResults.html', club=_club, team=_team)
except Exception as e:
print(e)
@routes.route('/convenor/playerDbCreate')
@basic_auth.required
def playerDbCreate():
sql = "SELECT club FROM _clubTeams GROUP BY club ORDER BY club"
clubs = sql_read(sql)
form = playerDbCreateForm()
return render_template('_convenorPlayerDbCreate.html', data=clubs, form=form)
@routes.route('/convenor/playerDbCreateResults', methods=['POST'])
@basic_auth.required
def playerDbCreateResults():
try:
_club = request.form['clubName']
# _year = request.form['year']
_year = "2018"
if _club and request.method == 'POST':
sql = "CREATE TABLE IF NOT EXISTS _" + _club + "_players (playerTeam varchar(6) NOT NULL, playerForenames varchar(50) NOT NULL, playerSurname varchar(30) NOT NULL, playerNickName varchar(30), playerChineseName varchar(10) CHARACTER SET utf8, playerEmail varchar(255) NOT NULL, playerDob DATE NOT NULL, playerHkid varchar(20) NOT NULL, playerNumber smallint NOT NULL, playerTelNumber varchar(30) NOT NULL, PRIMARY KEY (playerNumber))"
sql_write(sql)
return render_template('_convenorPlayerDbCreateResults.html', club=_club, year=_year)
except Exception as e:
print(e)
@routes.route('/convenor/playerAdd')
@basic_auth.required
def convenorAddPlayer():
sql = "SELECT hockeyClub, logoURL FROM mensHockeyClubs ORDER BY hockeyClub"
clubs = sql_read_static(sql)
form = addPlayerForm()
form.playerClub.choices = [(club['hockeyClub'], club['hockeyClub']) for club in clubs]
clubLogo = clubs[0]['logoURL']
return render_template('_convenorPlayerAdd.html', form=form, clubLogo=clubLogo)
@routes.route('/convenor/playerAddResult', methods=['POST'])
@basic_auth.required
def convenorAddPlayerResult():
try:
# _year = request.form['year']
_year = "2018"
_club = request.form['playerClub']
_team = request.form['playerTeam']
_playerForename = request.form['playerForenames']
_surname = request.form['playerSurnames']
_playerSurname = _surname.replace("'", "\\'")
_playerNickname = request.form['playerNickname']
_playerChineseName = request.form['playerChineseName']
_playerChineseName_enc = _playerChineseName.encode("utf-8")
_playerEmail = request.form['playerEmailAddress']
_playerDob = request.form['playerDob']
_playerHkid = request.form['playerHkid']
_playerNumber = request.form['playerNumber']
_playerTelNumber = request.form['playerTelNumber']
if _team and _playerSurname and _playerHkid and _playerNumber and request.method == 'POST':
sql = "INSERT INTO _" + _club + "_players (playerTeam, playerForenames, playerSurname, playerNickname, playerChineseName, playerEmail, playerDob, playerHkid, playerNumber, playerTelNumber) VALUES ('" + _team + "', '" + _playerForename + "', '" + _playerSurname + "', '" + _playerNickname + "', '" + _playerChineseName_enc + "', '" + _playerEmail + "', '" + _playerDob + "', '" + _playerHkid + "', '" + _playerNumber + "', '" + _playerTelNumber + "')"
print(_team)
print(sql)
sql_write(sql)
return render_template('_convenorPlayerAddResults.html', club=_club, firstname=_playerForename, nickname=_playerNickname, surname=_surname, shirt=_playerNumber)
except Exception as e:
print(e)
@routes.route('/convenor/squadList')
@basic_auth.required
def convenorSquadList():
sql = "SELECT team FROM _clubTeams WHERE club='HKFC' ORDER BY team"
teams = sql_read(sql)
form = squadListForm()
return render_template('_convenorSquadList.html', data=teams, form=form)
@routes.route('/convenor/squadListResults', methods=['POST'])
@basic_auth.required
def convenorSquadListResults():
try:
_team = request.form['teamName']
# validate that this data has been entered
if _team and request.method == 'POST':
sql = "SELECT playerForenames, playerSurname, playerNickname, playerChineseName, playerEmail, playerDob, playerHkid, playerNumber, playerTelNumber FROM _HKFC_players WHERE (playerTeam='" + _team + "') ORDER BY playerNumber"
rows = sql_read(sql)
table = convenorSquadListTable(rows)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('_convenorSquadListResults.html', table=table, _team=_team)
else:
return 'Invalid search data entered'
except Exception as e:
print(e)
@routes.route('/convenor/editPlayer', methods=['POST'])
@basic_auth.required
def convenorEditPlayer():
_playerNumber = request.args['playerNumber']
sql = "SELECT playerTeam, playerForenames, playerSurname, playerNickname, playerChineseName, playerEmail, playerDob, playerHkid, playerNumber, playerTelNumber FROM _HKFC_players WHERE playerNumber='" + _playerNumber + "'"
sql2 = "SELECT hockeyClub, logoURL FROM mensHockeyClubs ORDER BY hockeyClub"
playerData = sql_read(sql)
print(playerData)
clubs = sql_read_static(sql2)
form = addPlayerForm()
form.playerClub.choices = [(club['hockeyClub'], club['hockeyClub']) for club in clubs]
form.playerForenames.data = playerData[0]['playerForenames']
form.playerSurnames.data = playerData[0]['playerSurname']
form.playerNickname.data = playerData[0]['playerNickname']
form.playerChineseName.data = playerData[0]['playerChineseName']
form.playerEmailAddress.data = playerData[0]['playerEmail']
form.playerDob.data = playerData[0]['playerDob']
form.playerHkid.data = playerData[0]['playerHkid']
form.playerNumber.data = playerData[0]['playerNumber']
form.playerTelNumber.data = playerData[0]['playerTelNumber']
return render_template('_convenorPlayerEdit.html', data=playerData, form=form)
@routes.route('/convenor/deletePlayer', methods=['POST'])
@basic_auth.required
def convenorDeletePlayer():
_playerNumber = request.args['playerNumber']
sql = "DELETE FROM _HKFC_players WHERE playerNumber=" + _playerNumber + ""
sql_write(sql)
return render_template('_hkfcPlayerDeleted.html', number=_playerNumber)
@routes.route('/convenor/editPlayerResult', methods=['POST'])
@basic_auth.required
def convenorEditPlayerResult():
try:
# _year = request.form['year']
_year = "2018"
_club = request.form['playerClub']
_team = request.form['playerTeam']
_playerForename = request.form['playerForenames']
_surname = request.form['playerSurnames']
_playerSurname = _surname.replace("'", "\\'")
_playerNickname = request.form['playerNickname']
_playerChineseName = request.form['playerChineseName']
_playerChineseName_enc = _playerChineseName.encode("utf-8")
_playerEmail = request.form['playerEmailAddress']
_playerDob = request.form['playerDob']
_playerHkid = request.form['playerHkid']
_playerNumber = request.form['playerNumber']
_playerTelNumber = request.form['playerTelNumber']
if _team and _playerSurname and _playerHkid and _playerNumber and request.method == 'POST':
sql = "UPDATE _" + _club + "_players SET playerTeam='" + _team + "', playerForenames='" + _playerForename + "', playerSurname='" + _playerSurname + "', playerNickname='" + _playerNickname + "', playerChineseName='" + _playerChineseName_enc + "', playerEmail='" + _playerEmail + "', playerDob='" + _playerDob + "', playerHkid='" + _playerHkid + "', playerTelNumber='" + _playerTelNumber + "' WHERE playerNumber='" + _playerNumber + "'"
sql_write(sql)
return render_template('_convenorEditPlayerResults.html', club=_club, firstname=_playerForename, nickname=_playerNickname, surname=_playerSurname, shirt=_playerNumber)
except Exception as e:
print(e)
@routes.route('/convenor/fixtureList')
@basic_auth.required
def convenorFixturesList():
sql = "SELECT date, division, homeTeam, awayTeam, venue, time, umpire1, umpire2 FROM hockeyFixtures"
rows = sql_read(sql)
table = convenorFixtureList(rows)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('_convenorFixtureList.html', table=table)

View File

@ -1,355 +0,0 @@
#import MySQLdb
import pymysql
import os
import json
import datetime
from datetime import datetime
from flask import render_template, request, jsonify, flash
from flask_basicauth import BasicAuth
from app import app, randomUrlSuffix
from readSettings import mySettings
from dbWrite import sql_write, sql_write_static, sql_read, sql_read_static
from tables import matchSquadTable, convenorFixtureList
from forms import adminSettingsForm, motmForm, goalsAssistsForm, adminSettingsForm2
from . import routes
app.config['BASIC_AUTH_USERNAME'] = 'admin'
app.config['BASIC_AUTH_PASSWORD'] = 'letmein'
basic_auth = BasicAuth(app)
@routes.route('/hkfc-d/motm/<randomUrlSuffix>')
def hkfcD_motm_vote(randomUrlSuffix):
sql = "SELECT playerNumber, playerForenames, playerSurname, playerNickname FROM _hkfcD_matchSquad ORDER BY RAND()"
sql2 = "SELECT nextClub, nextTeam, nextDate, oppoLogo, hkfcLogo, currMotM, currDotD, nextFixture FROM hkfcDAdminSettings"
rows = sql_read(sql)
nextInfo = sql_read_static(sql2)
nextClub = nextInfo[0]['nextClub']
nextTeam = nextInfo[0]['nextTeam']
nextFixture = nextInfo[0]['nextFixture']
hkfcLogo = nextInfo[0]['hkfcLogo']
oppoLogo = nextInfo[0]['oppoLogo']
currMotM = nextInfo[0]['currMotM']
currDotD = nextInfo[0]['currDotD']
oppo = nextTeam
sql3 = "SELECT 2019_hockeyResults.hockeyFixtures.date, hockeyResults.hkfcDAdminSettings.nextFixture FROM 2019_hockeyResults.hockeyFixtures INNER JOIN hockeyResults.hkfcDAdminSettings ON 2019_hockeyResults.hockeyFixtures.fixtureNumber = hockeyResults.hkfcDAdminSettings.nextFixture"
nextMatchDate = sql_read(sql3)
nextDate = nextMatchDate[0]['date']
formatDate = datetime.strftime(nextDate, '%A, %d %B %Y')
sql3 = "SELECT playerPictureURL FROM _HKFC_players INNER JOIN hockeyResults.hkfcDAdminSettings ON _HKFC_players.playerNumber=hockeyResults.hkfcDAdminSettings.currMotM"
sql4 = "SELECT playerPictureURL FROM _HKFC_players INNER JOIN hockeyResults.hkfcDAdminSettings ON _HKFC_players.playerNumber=hockeyResults.hkfcDAdminSettings.currDotD"
motm = sql_read(sql3)
dotd = sql_read(sql4)
motmURL = motm[0]['playerPictureURL']
dotdURL = dotd[0]['playerPictureURL']
sql5 = "SELECT comment FROM _motmComments INNER JOIN hockeyResults.hkfcDAdminSettings ON _motmComments.matchDate=hockeyResults.hkfcDAdminSettings.nextDate ORDER BY RAND() LIMIT 1"
comment = sql_read(sql5)
if comment == "":
comment = "No comments added yet"
form = motmForm()
sql6 = "SELECT motmUrlSuffix FROM hockeyResults.hkfcDAdminSettings WHERE userid='admin'"
urlSuff = sql_read_static(sql6)
randomSuff = urlSuff[0]['motmUrlSuffix']
print(randomSuff)
if randomSuff == randomUrlSuffix:
return render_template('_hkfcDMotmVote.html', data=rows, comment=comment, formatDate=formatDate, matchNumber=nextFixture, oppo=oppo, hkfcLogo=hkfcLogo, oppoLogo=oppoLogo, dotdURL=dotdURL, motmURL=motmURL, form=form)
else:
return render_template('_error.html')
@routes.route('/hkfc-d/comments', methods=['GET', 'POST'])
def hkfcd_match_comments():
sql = "SELECT nextClub, nextTeam, nextDate, oppoLogo, hkfcLogo FROM hkfcDAdminSettings"
row = sql_read_static(sql)
# nextTeam already seems to include all the team+club details
# _oppo = row[0]['nextClub'] + " " + row[0]['nextTeam']
_oppo = row[0]['nextClub']
commentDate = row[0]['nextDate'].strftime('%Y-%m-%d')
_matchDate = row[0]['nextDate'].strftime('%Y_%m_%d')
hkfcLogo = row[0]['hkfcLogo']
oppoLogo = row[0]['oppoLogo']
if request.method == 'POST':
_comment = request.form['matchComment']
if _comment != 'Optional comments added here':
_fixed_comment = _comment.replace("'", "\\'")
sql3 = "INSERT INTO _motmComments (matchDate, opposition, comment) VALUES ('" + commentDate + "', '" + _oppo + "', '" + _fixed_comment + "')"
sql_write(sql3)
sql = "SELECT comment FROM _motmComments WHERE matchDate='" + _matchDate + "' ORDER BY RAND()"
comments = sql_read(sql)
return render_template('_hkfcDMatchComments.html', comments=comments, hkfcLogo=hkfcLogo, oppoLogo=oppoLogo)
@routes.route('/hkfc-d/statAdmin', methods=['GET', 'POST'])
@basic_auth.required
def hkfc_d_stats_admin():
form = goalsAssistsForm()
sql = "SELECT date, homeTeam, awayTeam, venue, fixtureNumber FROM hockeyFixtures WHERE homeTeam='HKFC D' OR awayTeam='HKFC D'"
matches = sql_read(sql)
form.match.choices = [(match['fixtureNumber'], match['date']) for match in matches]
sql2 = "SELECT playerNumber, playerNickname FROM _hkfcD_matchSquad"
players = sql_read(sql2)
return render_template('_goalsAssistsAdmin.html', data=players, form=form)
@routes.route('/hkfc-d/goalsAssistsSubmit', methods=['POST'])
@basic_auth.required
def goalsAssistsSubmit():
try:
data = request.form
playerName = request.form.getlist('playerName')
playerNumber = request.form.getlist('playerNumber')
assists = request.form.getlist('assists')
goals = request.form.getlist('goals')
match = request.form['match']
for idx, player in enumerate(playerNumber):
sql = "INSERT INTO _hkfc_d_motm (playerNumber, playerName, assistsTotal, goalsTotal, assists_" + match + ", goals_" + match + ") SELECT playerNumber, playerNickname, '" + assists[idx] + "', '" + goals[idx] + "', '" + assists[idx] + "', '" + goals[idx] + "' FROM _HKFC_players WHERE playerNumber='" + player + "' ON DUPLICATE KEY UPDATE assistsTotal = assistsTotal + " + assists[idx] + ", goalsTotal = goalsTotal + " + goals[idx] + ", assists_" + match + " = " + assists[idx] + ", goals_" + match + " = " + goals[idx] + ""
sql_write(sql)
except Exception as e:
print(e)
finally:
return render_template('_hkfcDGoalsThanks.html', data=data)
@routes.route('/hkfc-d/motmAdmin', methods=['GET', 'POST'])
@basic_auth.required
def hkfcDMotmAdmin():
form = adminSettingsForm2()
prevFixture = mySettings('prevFixture')
if prevFixture is None:
prevFixture = '1'
else:
prevFixture = str(prevFixture)
if request.method == 'POST':
if form.saveButton.data:
print('Saved')
else:
print('Activated')
_nextTeam = request.form['nextOppoTeam']
_nextFixture = request.form['nextMatch']
_currMotM = request.form['currMotM']
_currDotD = request.form['currDotD']
sql1 = "SELECT club FROM _clubTeams WHERE displayName='" + _nextTeam + "'"
_nextClubName = sql_read_static(sql1)
_nextClub = _nextClubName[0]['club']
sql = "UPDATE hkfcDAdminSettings SET nextFixture='" + _nextFixture + "', nextClub='" + _nextClub + "', nextTeam='" + _nextTeam + "', currMotM=" + _currMotM + ", currDotD=" + _currDotD + ""
sql_write_static(sql)
sql2 = "UPDATE hkfcDAdminSettings INNER JOIN mensHockeyClubs ON hkfcDAdminSettings.nextClub = mensHockeyClubs.hockeyClub SET hkfcDAdminSettings.oppoLogo = mensHockeyClubs.logoURL WHERE mensHockeyClubs.hockeyClub='" + _nextClub + "'"
sql_write_static(sql2)
if form.saveButton.data:
flash('Settings saved!')
urlSuffix = randomUrlSuffix(8)
print(urlSuffix)
sql3 = "UPDATE hkfcDAdminSettings SET motmUrlSuffix='" + urlSuffix + "' WHERE userid='admin'"
sql_write_static(sql3)
flash('MotM URL https://hk-hockey.appspot.com/hkfc-d/motm/'+urlSuffix)
elif form.activateButton.data:
sql4 = "ALTER TABLE _hkfc_d_motm ADD COLUMN motm_" + _nextFixture + " smallint DEFAULT 0, ADD COLUMN dotd_" + _nextFixture + " smallint DEFAULT 0, ADD COLUMN assists_" + _nextFixture + " smallint DEFAULT 0, ADD COLUMN goals_" + _nextFixture + " smallint DEFAULT 0 "
sql_write(sql4)
sql5 = "SELECT motmUrlSuffix FROM hkfcDAdminSettings WHERE userid='admin'"
tempSuffix = sql_read_static(sql5)
currSuffix = tempSuffix[0]['motmUrlSuffix']
print(currSuffix)
flash('Man of the Match vote is now activated')
flash('MotM URL https://hk-hockey.appspot.com/hkfc-d/motm/'+currSuffix)
else:
flash('Something went wrong - check with Smithers')
sql7 = "SELECT date, homeTeam, awayTeam, venue, fixtureNumber FROM hockeyFixtures WHERE homeTeam='HKFC D' OR awayTeam='HKFC D'"
matches = sql_read(sql7)
form.nextMatch.choices = [(match['fixtureNumber'], match['date']) for match in matches]
sql4 = "SELECT hockeyClub FROM mensHockeyClubs ORDER BY hockeyClub"
sql5 = "SELECT nextClub, oppoLogo FROM hkfcDAdminSettings"
sql6 = "SELECT playerNumber, playerForenames, playerSurname FROM _hkfcD_matchSquad_" + prevFixture + " ORDER BY playerForenames"
clubs = sql_read_static(sql4)
settings = sql_read_static(sql5)
players = sql_read(sql6)
form.nextOppoClub.choices = [(oppo['hockeyClub'], oppo['hockeyClub']) for oppo in clubs]
form.currMotM.choices = [(player['playerNumber'], player['playerForenames'] + " " + player['playerSurname']) for player in players]
form.currDotD.choices = [(player['playerNumber'], player['playerForenames'] + " " + player['playerSurname']) for player in players]
clubLogo = settings[0]['oppoLogo']
return render_template('_hkfcDMotmAdmin.html', form=form, nextOppoLogo=clubLogo)
@routes.route('/hkfc-d/motmAdmin/<club>')
def hkfc_d_admin_team(club):
sql = "SELECT team FROM _clubTeams WHERE club='" + club + "'"
myteams = sql_read(sql)
return jsonify(myteams)
@routes.route('/hkfc-d/getLogo/<club>')
def hkfc_d_get_logo(club):
sql = "SELECT logoURL FROM mensHockeyClubs WHERE hockeyClub='" + club + "'"
clubLogo = sql_read(sql)
return jsonify(clubLogo)
@routes.route('/hkfc-d/motmAdmin2/<fixture>')
def hkfc_d_admin_team2(fixture):
sql = "SELECT homeTeam, awayTeam FROM hockeyFixtures WHERE fixtureNumber='" + fixture + "'"
myteams = sql_read(sql)
if myteams[0]['homeTeam'].startswith("HKFC"):
nextOppo = myteams[0]['awayTeam']
else:
nextOppo = myteams[0]['homeTeam']
sql2 = "SELECT club FROM _clubTeams WHERE displayName ='" + nextOppo + "'"
return jsonify(nextOppo)
@routes.route('/hkfc-d/motmAdminLogo2/<fixture>')
def hkfc_d_admin_logo2(fixture):
sql = "SELECT homeTeam, awayTeam FROM hockeyFixtures WHERE fixtureNumber='" + fixture + "'"
myteams = sql_read(sql)
if myteams[0]['homeTeam'].startswith("HKFC D"):
nextOppo = myteams[0]['awayTeam']
else:
nextOppo = myteams[0]['homeTeam']
sql2 = "SELECT club FROM _clubTeams WHERE displayName ='" + nextOppo + "'"
clubs = sql_read_static(sql2)
clubName = clubs[0]['club']
sql3 = "SELECT logoUrl FROM mensHockeyClubs WHERE hockeyClub ='" + clubName + "'"
logo = sql_read_static(sql3)
clubLogo = logo[0]['logoUrl']
return jsonify(clubLogo)
@routes.route('/hkfc-d/statsAdmin/<fixture>')
def hkfc_dstatsAdminLookup(fixture):
sql = "SELECT homeTeam, awayTeam FROM hockeyFixtures WHERE fixtureNumber='" + fixture + "'"
teams = sql_read(sql)
#### The below SQL could be used to try and populate the team sheet for goals and assists after the match has been committed. TODO
# sql2 = "SELECT playerNumber, playerNickname FROM _hkfcD_matchSquad_" + fixture + ""
# players = sql_read(sql2)
# return jsonify(teams, players)
#### Return the teams to the javascript code.
return jsonify(teams)
@routes.route('/hkfc-d/vote-thanks', methods=['POST'])
def hkfcD_vote_thanks():
try:
_motm = request.form['motmVote']
_dotd = request.form['dotdVote']
_comments = request.form['motmComment']
_fixed_comments = _comments.replace("'", "\\'")
_matchDate = request.form['matchNumber']
_oppo = request.form['oppo']
if _motm and _dotd and request.method == 'POST':
sql = "INSERT INTO _hkfc_d_motm (playerNumber, playerName, motmTotal, motm_" + _matchDate + ") SELECT playerNumber, playerNickname, '1', '1' FROM _HKFC_players WHERE playerNumber='" + _motm + "' ON DUPLICATE KEY UPDATE motmTotal = motmTotal + 1, motm_" + _matchDate + " = motm_" + _matchDate + " + 1"
sql2 = "INSERT INTO _hkfc_d_motm (playerNumber, playerName, dotdTotal, dotd_" + _matchDate + ") SELECT playerNumber, playerNickname, '1', '1' FROM _HKFC_players WHERE playerNumber='" + _dotd + "' ON DUPLICATE KEY UPDATE dotdTotal = dotdTotal + 1, dotd_" + _matchDate + " = dotd_" + _matchDate + " + 1"
if _comments == "":
print("No comment")
elif _comments == "Optional comments added here":
print("No comment")
else:
### The matchDate has been replaced with the matchNumber - this should be corrected at some point (via a fixture table lookup)
sql3 = "INSERT INTO _motmComments (_matchDate, opposition, comment) VALUES ('" + _matchDate + "', '" + _oppo + "', '" + _fixed_comments + "')"
sql_write(sql3)
sql_write(sql)
sql_write(sql2)
return render_template('_hkfcDVoteThanks.html')
else:
return 'Ouch ... something went wrong here'
except Exception as e:
print(e)
finally:
print('Votes cast')
@routes.route('/hkfc-d/vote-results')
def hkfcD_vote_results():
_matchDate = str(mySettings('fixture'))
print(_matchDate)
sql = "SELECT playerName, motm_" + _matchDate + ", dotd_" + _matchDate + " FROM _hkfc_d_motm WHERE (motm_" + _matchDate + " > '0') OR (dotd_" + _matchDate + " > '0')"
print(sql)
rows = sql_read(sql)
print(rows)
return json.dumps(rows)
@routes.route('/hkfc-d/poty-results')
def hkfcD_poty_results():
sql = "SELECT playerName, motmTotal, dotdTotal FROM _hkfc_d_motm WHERE (motmTotal > '0') OR (dotdTotal > '0')"
print(sql)
rows = sql_read(sql)
return json.dumps(rows)
@routes.route('/hkfc-d/voting')
@basic_auth.required
def hkfcD_voting():
matchDate = mySettings('fixture')
return render_template('_hkfcDVoteChart.html', _matchDate=matchDate)
@routes.route('/hkfc-d/poty')
@basic_auth.required
def hkfcD_poty():
return render_template('_hkfcDPotYChart.html')
@routes.route('/hkfc-d/matchSquad')
@basic_auth.required
def hkfcD_match_squad():
sql1 = "SELECT team from _clubTeams WHERE club='HKFC' ORDER BY team"
sql2 = "SELECT playerTeam, playerForenames, playerSurname, playerNickname, playerNumber FROM _HKFC_players"
teams = sql_read(sql1)
players = sql_read(sql2)
return render_template('_hkfcDMatchSquad.html', teams=teams, players=players)
@routes.route('/hkfc-d/matchSquadSubmit', methods=['POST'])
@basic_auth.required
def hkfcD_match_squad_submit():
_playerNumbers = request.form.getlist('playerNumber')
for _playerNumber in _playerNumbers:
sql = "INSERT INTO _hkfcD_matchSquad (playerNumber, playerForenames, playerSurname, playerNickname) SELECT playerNumber, playerForenames, playerSurname, playerNickname FROM _HKFC_players WHERE playerNumber='" + _playerNumber + "'"
sql_write(sql)
sql2 = "SELECT playerNumber, playerForenames, playerSurname, playerNickname FROM _hkfcD_matchSquad"
players = sql_read(sql2)
table = matchSquadTable(players)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('_hkfcDMatchSquadSelected.html', table=table)
@routes.route('/hkfc-d/matchSquadList')
@basic_auth.required
def hkfcD_match_squad_list():
sql = "SELECT playerNumber, playerForenames, playerSurname, playerNickname FROM _hkfcD_matchSquad"
players = sql_read(sql)
table = matchSquadTable(players)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('_hkfcDMatchSquadSelected.html', table=table)
@routes.route('/convenor/delPlayerFromSquad', methods=['POST'])
@basic_auth.required
def delPlayerFromSquad():
_playerNumber = request.args['playerNumber']
sql = "DELETE FROM _hkfcD_matchSquad WHERE playerNumber=" + _playerNumber + ""
sql_write(sql)
return render_template('_hkfcDPlayerRemoved.html', number=_playerNumber)
@routes.route('/hkfc-d/matchSquadReset')
@basic_auth.required
def hkfcD_matchSquadReset():
_matchNumber = str(mySettings('fixture'))
print(_matchNumber)
sql1 = "RENAME TABLE _hkfcD_matchSquad TO _hkfcD_matchSquad_" + _matchNumber + ""
sql2 = "CREATE TABLE _hkfcD_matchSquad (playerNumber smallint UNIQUE, playerForenames varchar(50), playerSurname varchar(30), playerNickname varchar(30) NOT NULL, PRIMARY KEY (playerNumber))"
sql3 = "UPDATE hkfcDAdminSettings SET prevFixture='" + _matchNumber + "'"
sql_write(sql1)
sql_write(sql2)
sql_write_static(sql3)
return render_template('_hkfcDMatchSquadReset.html')
@routes.route('/hkfc-d/fixtureList')
def hkfcDFixtures():
sql = "SELECT date, division, homeTeam, awayTeam, venue, time, umpire1, umpire2 FROM hockeyFixtures WHERE homeTeam='HKFC D' OR awayTeam='HKFC D'"
rows = sql_read(sql)
table = convenorFixtureList(rows)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('_convenorFixtureList.html', table=table)

View File

@ -1,35 +0,0 @@
#import MySQLdb
import pymysql
from dbWrite import sql_read, sql_read_static
from flask import render_template, request, jsonify
from forms import searchForm, playerRecordsForm, teamRecordsForm, clubPlayingRecordsForm
from . import routes
from tables import Results, matchCardHome, matchCardAway
import datetime
from datetime import date
@routes.route('/matches/')
def matchDetails():
return 'hello'
@routes.route('/matches/<id>')
def matchLookup(id):
sql = "SELECT * FROM _mensResults WHERE matchNumber=" + id + ""
matchDetails = sql_read(sql)
matchTable = Results(matchDetails)
matchTable.border = True
matchTable.classes = ['table-striped', 'table-condensed', 'table-hover']
home = matchDetails[0]['matchHomeClub'].lower() + matchDetails[0]['matchHomeTeam']
away = matchDetails[0]['matchAwayClub'].lower() + matchDetails[0]['matchAwayTeam']
sql2 = "SELECT playerNumber, playerName, " + id + "goals, " + id + "capt FROM _" + home + " WHERE " + id + "played=1"
sql3 = "SELECT playerNumber, playerName, " + id + "goals, " + id + "capt FROM _" + away + " WHERE " + id + "played=1"
homeCard = sql_read(sql2)
homeTable = matchCardHome(homeCard)
homeTable.border = True
homeTable.classes = ['table-striped', 'table-condensed', 'table-hover']
awayCard = sql_read(sql3)
awayTable = matchCardAway(awayCard)
awayTable.border = True
awayTable.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('_matchDetails.html', matchTable=matchTable, homeTable=homeTable, awayTable=awayTable)

View File

@ -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'

View File

@ -1,14 +0,0 @@
from flask import render_template
from . import routes
@routes.route('/')
def index():
return render_template('dashboard.html')
@routes.route('/dashboard')
def dashboard():
return render_template('dashboard.html')
@routes.route('/about')
def about():
return render_template('_about.html')

View File

@ -0,0 +1,17 @@
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('/')
def deploySelect():
namespaces =
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)

View File

@ -1,87 +0,0 @@
from flask_table import Table, Col, LinkCol, ButtonCol
class Results(Table):
matchNumber = Col('Match Number')
matchDate = Col('Date')
matchTime = Col('Time')
matchHomeClub = Col('Home Club')
matchHomeTeam = Col('Home Team')
matchHomeScore = Col('Score')
matchAwayScore = Col('Score')
matchAwayClub = Col('Away Club')
matchAwayTeam = Col('Away Team')
matchUmpire1 = Col('Umpire 1')
matchUmpire2 = Col('Umpire 2')
matchOfficial = Col('Match Official')
id = Col('id', show=False)
class matchCardHome(Table):
playerNumber = Col('Player Number')
playerName = Col('Player Name')
class matchCardAway(Table):
playerNumber = Col('Player Number')
playerName = Col('Player Name')
class playerResults(Table):
playerNumber = Col('Player Number')
playerName = Col('Player Name')
appearances = Col('Appearances')
goals = Col('Goals')
class teamResults(Table):
opposition = Col('Opponent')
played = Col('Played')
matchesWon = Col('Won')
matchesDrawn = Col('Drawn')
matchesLost = Col('Lost')
goalsFor = Col('For')
goalsAgainst = Col('Against')
class clubPlayingRecord(Table):
playerNumber = Col('Player Number')
playerName = Col('Player Name')
appearances_A = Col('A Team Appearances')
appearances_B = Col('B Team Appearances')
appearances_C = Col('C Team Appearances')
appearances_D = Col('D Team Appearances')
appearances_E = Col('E Team Appearances')
appearances_F = Col('F Team Appearances')
appearances_G = Col('G Team Appearances')
appearances_H = Col('H Team Appearances')
class clubList(Table):
club = Col('Club Name')
team = Col('Team')
league = Col('Division')
class convenorSquadListTable(Table):
playerNumber = Col('Shirt Number')
playerForenames = Col('Forenames')
playerSurname = Col('Surname')
playerNickname = Col('Nickname')
playerChineseName = Col('Chinese Name')
playerEmail = Col('Email')
playerDob = Col('Date of Birth')
playerHkid = Col('HK ID Number')
playerTelNumber = Col('Contact Number')
edit = ButtonCol('Edit', 'routes.convenorEditPlayer', url_kwargs=dict(playerNumber='playerNumber'), button_attrs={"type" : "submit", "class" : "btn btn-primary"})
delete = ButtonCol('Delete', 'routes.convenorDeletePlayer', url_kwargs=dict(playerNumber='playerNumber'), button_attrs={"type" : "submit", "class" : "btn btn-danger"})
class matchSquadTable(Table):
playerNumber = Col('Player Number')
playerNickname = Col('Nickname')
playerSurname = Col('Surname')
playerForenames = Col('Forenames')
delete = ButtonCol('Delete', 'routes.delPlayerFromSquad', url_kwargs=dict(playerNumber='playerNumber'), button_attrs={"type" : "submit", "class" : "btn btn-danger"})
class convenorFixtureList(Table):
date = Col('Date')
division = Col('Division')
homeTeam = Col('Home Team')
awayTeam = Col('Away Team')
venue = Col('Venue')
time = Col('Time')
umpire1 = Col('Umpire 1')
umpire2 = Col('Umpire 2')

View File

@ -1,51 +0,0 @@
First off, this page needs to be formatted ...
This web application was first put together in an attempt to make the HKHA historical results more acccessible. The current HKHA page is fairly useless, and makes an attempt to conceal historical results, which means in order to review previous season(s) results, you need to use a tool such https://web.archive.org and pick out snapshots of the HKHA website from the date you want to check.
The sad thing is that the HKHA do have these records on their web server, and they are even publicly accessible, they're just not publicly exposed. There is, unsurprisingly, no public API to this data, and instead the results (both the current season and previous seasons) are saved as individual ASP pages. Presumably these are created programmatically and then uploaded to the web server. The data is suitably embedded to make it annoying to extract.
On a separate server I have a job set up to download all the ASP files (this is only done once and only new files on the HKHA web server are retrieved in future requests). A series of bash and python scripts then extract out the data from each match card ASP file so that the following data can be uploaded to a MySQL database:
- Match Number
- Match Date
- Match Time
- Home Club
- Home Team
- Home Score
- Away Club
- Away Team
- Away Score
- Umpire 1
- Umpire 2
- Match Official
Separately, the line ups are then extracted and also uploaded to a MySQL database keeping track of player names, player numbers, appearances, goals, captaincy, and potentially whether they are a goalkeeper. Some teams are better than others about submitting goalkeeper information, so that tends to be a bit random. Some matchcards are 'blank' with no good reason given. When these are encountered, if there is a result on the card, this is recorded, and the player records are updated to reflect that a match took place, but no players are marked as having played. This isn't great, but given there is no data available, there isn't much that can be done here. I should also be tracking yellow/red cards, although this data also appears to be a bit hit and miss on the matchcard data.
Previous seasons are being uploaded/processed as and when I have time. Currently, 2014/15 season is as far back as the database goes - the data should be available back to 2009/10 though, and if I have time this will be uploaded also. Likewise there also appears to be the data for the equivalent ladies matches. If time permits, then this will also be added to the database and application.
As an extension of the match/player tracking side, I decided to add some convenor and team related functionality. The convenor functionality allows me to track the details of the club players I enter the details of. Much more manageable system than the HKHA currently provide, and helps me understand how to connect python to MySQL etc. The team functionality is to create an online MotM/DotD vote.
Initially, the MotM vote would generate a list of players from the players who had previously represented the team. This list was using match card data previously uploaded to the database, and worked fairly well. The drawbacks here were that people could vote for players who were not present at the match which isn't ideal. The player list presented was also originally sorted by the player number which could result in certain players being selected by 'default'. The player list code has been revised so that:
- The 'admin' user must submit a player list before the vote can take place (this is not dis-similar to the HKHA match card system)
- The player list presented is randomised.
- The player names are taken from a convenor maintained database table which means I can incorporate nicknames instead of the formal names used by the HKHA (if no nickname is created in the table, it falls back to using the formal name)
A match comments system has also been added so that players can add a comment on the match they are voting on (if they wish). The voting form also includes one randomly selected match comment (to allow for anyone who wants to try and influence future voters ...). There is a separate comment form so that comments can be added without needing to submit more votes.
At the moment, the vote is 'open'. No login is required and there is limited tracking of votes, which means it is feasible for one person to vote many times. Currently I'm relying on the honour system to keep the process working. It would be relatively straightforward to add a login function required to vote, but this might/would discourage voters.
ARCHITECTURE
The web application is coded with python and uses the flask web framework to run. The backend database is a MySQL database, which python connects easiy to. The flask web application is hosted on the Google Application Engine and the MySQL database is provided by the Google Cloud SQL. The usage levels are low enough that GAE should always qualify for free tier and the Cloud SQL cost is low and is currently being paid for by the free trial credit. The static images/files are uploaded to Google Cloud Storage and their locations are saved into the MySQL database as fields of the objects they represent (typically these are player pictures and other images used on the web application).
It's all very low traffic and therefore a cheap deployment, but with enough activity that it I can understand what works and what doesn't.
Future changes will involve saving various parameters to a settings table so that there is less (no) hardcoding of values which should allow for the whole application to be managed via the webpage. Currently the MotM/DotD tables need to be manually referenced and the Chart that the admin can check to see the vote values also needs to be hardcoded to use the correct tables. This requires a certain amount of manual configuration by the admin before the match is played. If various parameters (such as match date) can be moved to a settings table and read as needed then this would allow the MotM set up and activation to be performed via the web page alone.
More future changes will involve uploading the remaining data from the men's seasons, and then the ladies matches as well.
I'd also like to tidy up the interface and make it more consistent.
The code also needs to be reviewed (again) - and there are undoubtedly repeated bits of code. This is the result of:
a) not knowing python very well
b) only getting to spend short spells on this at random times

View File

@ -1,41 +0,0 @@
<ooctype html>
<head>
<title>List of player team appearances from 2018/19 season - Python Flask MySQL app</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
{%- for column in columns %}
<th>{{ column['Field'] }}</th>
{%- endfor %}
</thead>
<tbody>
{%- for row in rows %}
<tr>
{%- for column in columns %}
<td>{{ row[column['Field']] }}</td>
{%- endfor %}
</tr>
{%- endfor %}
</tbody>
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,31 +0,0 @@
{% extends "bootstrap/base.html" %}
{% block title %}
Add Club Form
{% endblock %}
{% block head %}
<link rel="stylesheet" media="screen" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content ="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
{% endblock %}
{% block body %}
<form method="post" action="/convenor/clubAddResult">
<legend>Add Hockey Club Form</legend>
{{ form.hidden_tag() }}
<div>
{{ form.clubName.label }}<br>
{{ form.clubName(class_="form-control") }}
<br>
{{ form.submit(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</div>
</form>
{% endblock %}

View File

@ -1,18 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - MotM and DotD vote *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Thanks for adding {{ data }} to the club database</h2>
<body>
This automatically adds the A team of {{ data }} to the database.
<p>
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>
</html>

View File

@ -1,26 +0,0 @@
<doctype html>
<head>
<title>List of Clubs and Teams - Python Flask MySQL CRUD</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-bordered">
{{ table }}
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,18 +0,0 @@
<html>
<head>
<title>*TESTING* Player Added to Database</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Thanks for editting {{ firstname }} {{ surname }} in the {{ club }} database</h2>
<body>
{{ firstname }} {{ surname }} with shirt number {{ shirt }} has been modified in the {{ club }} database for this season.
<p>
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>
</html>

View File

@ -1,48 +0,0 @@
<html>
<head>
<title>Edit Team Members</title>
</head>
<body>
<h1>Edit Team</h1>
<div>
<form action="/convenor/editSquadEnd" method="post" accept-charset="utf-8">
Team: {{ team }}<br>
<div>
<table border="1">
<tr>
<th> Club </th>
<th> Team </th>
<th> Forenames </th>
<th> Surname </th>
<th> Nickname </th>
<th> Chinese Name </th>
<th> Email </th>
<th> Date of Birth </th>
<th> HKID Number </th>
<th> Shirt Number </th>
<th> Tel Number </th>
</tr>
{% for member in form %}
<tr>
<td>HKFC</td>
<td contenteditable="true">{{ member.playerTeam }}</td>
<td contenteditable="true">{{ member.playerForenames }}</td>
<td contenteditable="true">{{ member.playerSurname }}</td>
<td contenteditable="true">{{ member.playerNickname }}</td>
<td contenteditable="true">{{ member.playerChineseName }}</td>
<td contenteditable="true">{{ member.playerEmailAddress }}</td>
<td contenteditable="true">{{ member.playerDob }}</td>
<td contenteditable="true">{{ member.playerHkid }}</td>
<td contenteditable="true">{{ member.playerNumber }}</td>
<td contenteditable="true">{{ member.playerTelNumber }}</td>
</tr>
{% endfor %}
</table>
</div>
<p>
<button type="submit" class="btn btn-success">Submit</button>
</p>
</form>
</div>
</body>
</html>

View File

@ -1,35 +0,0 @@
{% extends "bootstrap/base.html" %}
{% block title %}
List Team Squad
{% endblock %}
{% block head %}
<link rel="stylesheet" media="screen" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content ="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
{% endblock %}
{% block body %}
<form method="post" action="/convenor/editSquadList">
<legend>List Team Squad</legend>
{{ form.hidden_tag() }}
<div style="width: 10%">
<p>
<label for="teamName">Team:</label>
<select class="form-control" name="teamName" required>
{% for item in data %}
<option value={{ item.team }}>{{ item.team }}</option>
{% endfor %}
</select>
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
<button type="submit" class="btn btn-success">Submit</button>
</p>
</div>
</form>
{% endblock %}

View File

@ -1,26 +0,0 @@
<doctype html>
<head>
<title>Fixture List 2019/20 season</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-bordered">
{{ table }}
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,158 +0,0 @@
<html>
<head>
<title>HKFC Men's Convenor - Player Add form *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>HKFC Men's Convenor Add Player Record Form</h2>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<body onload="myFunction()">
<dl>
<p>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/convenor/playerAddResult" accept-charset="utf-8">
<legend>Add Player Form</legend>
<div class = "row">
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerClub.label }}</span>
{{ form.playerClub(class_="form-control") }}
</div>
</div>
<div class = "col-sm-2">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerTeam.label }}</span>
{{ form.playerTeam(class_="form-control") }}
</div>
</div>
<div class = "col-sm-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerNumber.label }}</span>
{{ form.playerNumber(class_="form-control") }}
</div>
</div>
</div>
<p/>
<div class = "row">
<div class = "col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerForenames.label }}</span>
{{ form.playerForenames(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerSurnames.label }}</span>
{{ form.playerSurnames(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerNickname.label }}</span>
{{ form.playerNickname(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerChineseName.label }}</span>
{{ form.playerChineseName(class_="form-control") }}
</div>
</div>
</div>
<p/>
<div class = "row">
<div class = "col-sm-5">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerEmailAddress.label }}</span>
{{ form.playerEmailAddress(class_="form-control") }}
</div>
</div>
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerTelNumber.label }}</span>
{{ form.playerTelNumber(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-5">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerDob.label }}</span>
{{ form.playerDob(class_="form-control") }}
</div>
</div>
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerHkid.label }}</span>
{{ form.playerHkid(class_="form-control") }}
</div>
</div>
</div>
<br>
{{ form.submit(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</form>
<div class="col-sm-6">
<img src="{{ clubLogo }}" height="90" id="clubLogo"/>
</div>
</div>
</div>
</p>
</dl>
</body>
<script>
var club_select = document.getElementById("playerClub");
var club_logo = document.getElementById("clubLogo");
var team_select = document.getElementById("playerTeam");
club_select.onchange = function() {myFunction()};
function myFunction() {
club = club_select.value;
fetch('/hkfc-d/motmAdmin/' + club).then(function(response) {
response.json().then(function(data) {
var optionHTML = '';
for (var team of data) {
optionHTML += '<option value="' + team.team + '">' + team.team + '</option>';
}
team_select.innerHTML = optionHTML;
})
});
fetch('/hkfc-d/getLogo/' + club).then(function(response) {
response.json().then(function(data) {
var HTML = '';
for (var logo of data) {
HTML += logo.logoURL;
}
club_logo.src = HTML;
})
});
}
</script>
</html>

View File

@ -1,18 +0,0 @@
<html>
<head>
<title>*TESTING* Player Added to Database</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Thanks for adding {{ firstname }} {{ surname }} to the {{ club }} database</h2>
<body>
{{ firstname }} {{ surname }} with shirt number {{ shirt }} has been added to the {{ club }} database for this season.
<p>
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>
</html>

View File

@ -1,36 +0,0 @@
{% extends "bootstrap/base.html" %}
{% block title %}
Add Team Table
{% endblock %}
{% block head %}
<link rel="stylesheet" media="screen" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content ="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
{% endblock %}
{% block body %}
<form method="post" action="/convenor/playerDbCreateResults">
<legend>Create Player Database for selected Club</legend>
{{ form.hidden_tag() }}
<div>
<p>
<label for="clubName">Club:</label>
<select class="form-control" name="clubName" required>
{% for item in data %}
<option value={{ item.club }}>{{ item.club }}</option>
{% endfor %}
</select>
</p>
<br>
{{ form.submit(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</div>
</form>
{% endblock %}

View File

@ -1,18 +0,0 @@
<html>
<head>
<title>*TESTING* CLub Player DB Creation Results</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Adding {{ club }} player database for season starting {{ year }}</h2>
<body>
A player database for {{ club }} for the season starting {{ year }} should now exist.
<p>
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>
</html>

View File

@ -1,159 +0,0 @@
<html>
<head>
<title>HKFC Men's Convenor - Player Add form *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>HKFC Men's Convenor Edit Player Record Form</h2>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<body onload="myFunction()">
{{ data }}
<dl>
<p>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/convenor/editPlayerResult" accept-charset="utf-8">
<legend>Edit Player Form</legend>
<div class = "row">
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerClub.label }}</span>
{{ form.playerClub(class_="form-control") }}
</div>
</div>
<div class = "col-sm-2">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerTeam.label }}</span>
{{ form.playerTeam(class_="form-control") }}
</div>
</div>
<div class = "col-sm-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerNumber.label }}</span>
{{ form.playerNumber(class_="form-control") }}
</div>
</div>
</div>
<p/>
<div class = "row">
<div class = "col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerForenames.label }}</span>
{{ form.playerForenames(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerSurnames.label }}</span>
{{ form.playerSurnames(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerNickname.label }}</span>
{{ form.playerNickname(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerChineseName.label }}</span>
{{ form.playerChineseName(class_="form-control") }}
</div>
</div>
</div>
<p/>
<div class = "row">
<div class = "col-sm-5">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerEmailAddress.label }}</span>
{{ form.playerEmailAddress(class_="form-control") }}
</div>
</div>
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerTelNumber.label }}</span>
{{ form.playerTelNumber(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-5">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerDob.label }}</span>
{{ form.playerDob(class_="form-control") }}
</div>
</div>
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">{{ form.playerHkid.label }}</span>
{{ form.playerHkid(class_="form-control") }}
</div>
</div>
</div>
<br>
{{ form.submit(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</form>
<div class="col-sm-6">
<img src="{{ clubLogo }}" height="90" id="clubLogo"/>
</div>
</div>
</div>
</p>
</dl>
</body>
<script>
var club_select = document.getElementById("playerClub");
var club_logo = document.getElementById("clubLogo");
var team_select = document.getElementById("playerTeam");
club_select.onchange = function() {myFunction()};
function myFunction() {
club = club_select.value;
fetch('/hkfc-d/motmAdmin/' + club).then(function(response) {
response.json().then(function(data) {
var optionHTML = '';
for (var team of data) {
optionHTML += '<option value="' + team.team + '">' + team.team + '</option>';
}
team_select.innerHTML = optionHTML;
})
});
fetch('/hkfc-d/getLogo/' + club).then(function(response) {
response.json().then(function(data) {
var HTML = '';
for (var logo of data) {
HTML += logo.logoURL;
}
club_logo.src = HTML;
})
});
}
</script>
</html>

View File

@ -1,35 +0,0 @@
{% extends "bootstrap/base.html" %}
{% block title %}
List Team Squad
{% endblock %}
{% block head %}
<link rel="stylesheet" media="screen" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content ="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
{% endblock %}
{% block body %}
<form method="post" action="/convenor/squadListResults">
<legend>List Team Squad</legend>
{{ form.hidden_tag() }}
<div style="width: 10%">
<p>
<label for="teamName">Team:</label>
<select class="form-control" name="teamName" required>
{% for item in data %}
<option value={{ item.team }}>{{ item.team }}</option>
{% endfor %}
</select>
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
<button type="submit" class="btn btn-success">Submit</button>
</p>
</div>
</form>
{% endblock %}

View File

@ -1,26 +0,0 @@
<doctype html>
<head>
<title>List of players from HKFC {{ _team }} Team for 2017/18 season</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-bordered">
{{ table }}
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,38 +0,0 @@
{% extends "bootstrap/base.html" %}
{% block title %}
Add Team Table
{% endblock %}
{% block head %}
<link rel="stylesheet" media="screen" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content ="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
{% endblock %}
{% block body %}
<form method="post" action="/convenor/teamAddResult">
<legend>Add Team Form</legend>
{{ form.hidden_tag() }}
<div>
<p>
<label for="clubName">Club:</label>
<select class="form-control" name="clubName" required>
{% for item in data %}
<option value={{ item.club }}>{{ item.club }}</option>
{% endfor %}
</select>
</p>
{{ form.teamName.label }}<br>
{{ form.teamName(class_="form-control") }}
<br>
{{ form.submit(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</div>
</form>
{% endblock %}

View File

@ -1,18 +0,0 @@
<html>
<head>
<title>*TESTING* - Team Add Results</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Thanks for adding {{ club }} {{ team }} to the club database</h2>
<body>
{{ club }} {{ team }} should now be added to the database.
<p>
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>
</html>

View File

@ -1 +0,0 @@
Bzzzzt. This is an error.

View File

@ -1,173 +0,0 @@
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
}
#squadForm {
background-color: #ffffff;
margin: 100px auto;
font-family: Raleway;
padding: 40px;
width: 40%;
min-width: 300px;
}
h1 {
text-align: center;
}
input {
padding: 10px;
width: 10%;
font-size: 17px;
font-family: Raleway;
border: 1px solid #aaaaaa;
}
/* Mark input boxes that gets an error on validation: */
input.invalid {
background-color: #ffdddd;
}
/* Hide all steps by default: */
.tab {
display: none;
}
button {
background-color: #4CAF50;
color: #ffffff;
border: none;
padding: 10px 20px;
font-size: 17px;
font-family: Raleway;
cursor: pointer;
}
button:hover {
opacity: 0.8;
}
#prevBtn {
background-color: #bbbbbb;
}
</style>
<head>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body onload="myFunction()">
{{ form.csrf_token }}
<form action="/hkfc-d/goalsAssistsSubmit" method="post" accept-charset="utf-8">
<h1>Allocate goals and assists</h1>
<div class="row row-no-gutters">
<div class = "col-md-3 col-md-offset-1">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Fixture Date</span>
{{ form.match(class_="form-control") }}
</div>
</div>
<div class = "col-md-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Home Team</span>
{{ form.homeTeam(class_="form-control") }}
</div>
</div>
</div>
<div class="row row-no-gutters">
<div class = "col-md-3 col-md-offset-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon3">Away Team</span>
{{ form.awayTeam(class_="form-control") }}
</div>
</div>
</div>
<div class="row row-no-gutters">
<div class = "col-md-1 col-md-offset-1">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Number</span>
</div>
</div>
<div class = "col-md-2">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Player</span>
</div>
</div>
<div class = "col-md-1">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Assists</span>
</div>
</div>
<div class = "col-md-1">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Goals</span>
</div>
</div>
</div>
</div>
<div id="data">
{% for item in data %}
<div class = "row row-no-gutters">
<div class = "col-md-1 col-md-offset-1" id="player-{{ loop.index }}">
{{ item.playerNumber }}
<input type="hidden" id="playerNumber" name="playerNumber" value="{{ item.playerNumber }}">
</div>
<div class = "col-md-2">
{{ item.playerNickname }}
<input type="hidden" id="playerName" name="playerName" value="{{ item.playerNickname }}">
</div>
<div class = "col-md-1">
{{ form.assists(class_="form-control") }}
</div>
<div class = "col-md-1">
{{ form.goals(class_="form-control") }}
</div>
</br>
</div>
{% endfor %}
</div>
<div class = "col-md-6 col-md-offset-1">
{{ form.submit(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</div>
</form>
<script>
var date_select = document.getElementById("match");
var homeTeam = document.getElementById("homeTeam");
var awayTeam = document.getElementById("awayTeam");
date_select.onchange = function() {myFunction()};
function myFunction() {
date = date_select.value;
fetch('/hkfc-d/statsAdmin/' + date).then(function(response) {
response.json().then(function(data) {
var HTML = '';
var HTML2 = '';
for (var team of data) {
HTML += team.homeTeam;
HTML2 += team.awayTeam;
}
homeTeam.value = HTML;
awayTeam.value = HTML2;
})
});
}
</script>
</body>
</html>

View File

@ -1,14 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - MotM and DotD admin *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Thanks for activating the MotM and DotD votes</h2>
<a href="/dashboard">Back to the dashboard</a>
<body>
</body>
</html>

View File

@ -1,18 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - Goals and Assists</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Thanks for submitting the goals and assists statistics</h2>
<body>
Smithers' army of Internet monkeys will now go about adding up the numbers ...
<p>
<img src="https://storage.googleapis.com/hk-hockey-data/images/monkey-typing-simpsons.jpg"></img>
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>
</html>

View File

@ -1,35 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - Match Comments *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h3>HKFC Men's D Team Match Comments</h3>
<h5>16th December 2018 - Aquila A</h5>
<h4><img src="{{ hkfcLogo }}" height="150"></img> <b>V</b> <img src="{{ oppoLogo }}" height="140"></img></h4>
<body>
This is an experimental option to add comments on the match - all submitted comments should appear here
<form method="post" action="/hkfc-d/comments" id="matchCommentForm">
<div>
<label for="matchComment">Match Comments (purely optional - 3000 character limit):</label>
<br/>
<textarea rows="4" cols="80" name="matchComment" form="matchCommentForm">Optional comments added here</textarea>
</div>
<button type="submit" class="btn btn-success">Submit</button>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</form>
<p><b>The wit and wisdom of the HKFC D team (in random order):</b>
<br/>
{% for item in comments %}
<i>{{ item.comment }}</i>
<br/>
<br/>
{% else %}
<i>No comments have been submitted yet.</i>
{% endfor %}
</p>
</body>
</html>

View File

@ -1,200 +0,0 @@
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
}
#squadForm {
background-color: #ffffff;
margin: 100px auto;
font-family: Raleway;
padding: 40px;
width: 40%;
min-width: 300px;
}
h1 {
text-align: center;
}
input {
padding: 10px;
width: 10%;
font-size: 17px;
font-family: Raleway;
border: 1px solid #aaaaaa;
}
/* Mark input boxes that gets an error on validation: */
input.invalid {
background-color: #ffdddd;
}
/* Hide all steps by default: */
.tab {
display: none;
}
button {
background-color: #4CAF50;
color: #ffffff;
border: none;
padding: 10px 20px;
font-size: 17px;
font-family: Raleway;
cursor: pointer;
}
button:hover {
opacity: 0.8;
}
#prevBtn {
background-color: #bbbbbb;
}
/* Make circles that indicate the steps of the form: */
.step {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbbbbb;
border: none;
border-radius: 50%;
display: inline-block;
opacity: 0.5;
}
.step.active {
opacity: 1;
}
/* Mark the steps that are finished and valid: */
.step.finish {
background-color: #4CAF50;
}
</style>
<body>
<form id="squadForm" action="/hkfc-d/matchSquadSubmit" method="post">
<h1>Add Players to Squad</h1>
<!-- One "tab" for each step in the form: -->
{% for team in teams %}
<div class="tab">{{ team.team }} Team Players
<p>
{% for item in players %}
{% if item.playerTeam == team.team %}
<label><input type="checkbox" name="playerNumber" value="{{ item.playerNumber }}">{{ item.playerNumber }} {{ item.playerForenames }} {{ item.playerSurname }}</label>
<br/>
{% endif %}
{% endfor %}
</p>
</div>
{% endfor %}
<div style="overflow:auto;">
<div style="float:right;">
<button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
<button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
</div>
</div>
<!-- Circles which indicates the steps of the form: -->
<div style="text-align:center;margin-top:40px;">
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
</div>
</form>
<script>
var currentTab = 0; // Current tab is set to be the first tab (0)
showTab(currentTab); // Display the crurrent tab
function showTab(n) {
// This function will display the specified tab of the form...
var x = document.getElementsByClassName("tab");
x[n].style.display = "block";
//... and fix the Previous/Next buttons:
if (n == 0) {
document.getElementById("prevBtn").style.display = "none";
} else {
document.getElementById("prevBtn").style.display = "inline";
}
if (n == (x.length - 1)) {
document.getElementById("nextBtn").innerHTML = "Submit";
} else {
document.getElementById("nextBtn").innerHTML = "Next";
}
//... and run a function that will display the correct step indicator:
fixStepIndicator(n)
}
function nextPrev(n) {
// This function will figure out which tab to display
var x = document.getElementsByClassName("tab");
// Exit the function if any field in the current tab is invalid:
// JDE ** Need to validate for this to work? ** if (n == 1 && !validateForm()) return false;
// Hide the current tab:
x[currentTab].style.display = "none";
// Increase or decrease the current tab by 1:
currentTab = currentTab + n;
// if you have reached the end of the form...
if (currentTab >= x.length) {
// ... the form gets submitted:
document.getElementById("squadForm").submit();
return false;
}
// Otherwise, display the correct tab:
showTab(currentTab);
}
function validateForm() {
// This function deals with validation of the form fields
var x, y, i, valid = true;
x = document.getElementsByClassName("tab");
y = x[currentTab].getElementsByTagName("input");
// A loop that checks every input field in the current tab:
for (i = 0; i < y.length; i++) {
// If a field is empty...
if (y[i].value == "") {
// add an "invalid" class to the field:
y[i].className += " invalid";
// and set the current valid status to false
valid = false;
}
}
// If the valid status is true, mark the step as finished and valid:
if (valid) {
document.getElementsByClassName("step")[currentTab].className += " finish";
}
return valid; // return the valid status
}
function fixStepIndicator(n) {
// This function removes the "active" class of all steps...
var i, x = document.getElementsByClassName("step");
for (i = 0; i < x.length; i++) {
x[i].className = x[i].className.replace(" active", "");
}
//... and adds the "active" class on the current step:
x[n].className += " active";
}
</script>
</body>
</html>

View File

@ -1,3 +0,0 @@
The table for the HKFC D team has been deleted and recreated (empty)
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>

View File

@ -1,26 +0,0 @@
<doctype html>
<head>
<title>List of players from HKFC {{ _team }} Team for 2017/18 season</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-bordered">
{{ table }}
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,105 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - MotM and DotD vote admin *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>HKFC Men's D Team MotM and DotD online vote admin page</h2>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<body onload="myFunction()">
<dl>
<p>
{{ form.csrf_token }}
<b>HKFC D Next Opponent:</b>
<br/>
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/hkfc-d/motmAdmin">
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Date:</span>
{{ form.nextMatch(class_="form-control") }}
</div>
</div>
</div>
</br>
<div class = "row">
<div class = "col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Opposition</span>
{{ form.nextOppoTeam(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Current Man of the Match:</span>
{{ form.currMotM(class_="form-control") }}
</div>
</div>
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Current Dick of the Day:</span>
{{ form.currDotD(class_="form-control") }}
</div>
</div>
</div>
<p>
{{ form.saveButton(class_="btn btn-success") }}
{{ form.activateButton(class_="btn btn-primary") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</p>
</form>
<div class="col-sm-4">
<img src="{{ nextOppoLogo }}" height="90" id="nextOppoLogo"/>
</div>
</div>
</div>
</p>
</dl>
<script>
var match_select = document.getElementById("nextMatch");
var club_logo = document.getElementById("nextOppoLogo");
var team_select = document.getElementById("nextOppoTeam");
match_select.onchange = function() {myFunction()};
function myFunction() {
match = match_select.value;
fetch('/hkfc-d/motmAdmin2/' + match).then(function(response) {
response.json().then(function(team) {
var optionHTML = '';
optionHTML += team;
team_select.value = optionHTML;
})
});
fetch('/hkfc-d/motmAdminLogo2/' + match).then(function(response) {
response.json().then(function(logo) {
var HTML = '';
HTML += logo;
club_logo.src = HTML;
})
});
}
</script>
</body>
</html>

View File

@ -1,83 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - MotM and DotD online vote *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h3>HKFC Men's D Team MotM and DotD online vote</h3>
<h5>{{ formatDate }}</h5>
<h4><img src="{{ hkfcLogo }}" height="150"></img> <b> </b> <img src="{{ oppoLogo }}" height="140"></img></h4>
<body>
<p><b>Randomly selected comment from the match:</b>
<br/>
{% for item in comment %}
<i>{{ item.comment }}</i>
{% endfor %}
</p>
<dl>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/hkfc-d/vote-thanks" id="motmForm" accept-charset="utf-8">
<input type="hidden" id="matchNumber" name="matchNumber" value="{{ matchNumber }}">
<input type="hidden" id="oppo" name="oppo" value="{{ oppo }}">
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Man of the Match</span>
<select class="form-control" name="motmVote" required>
{% for item in data %}
{% if item.playerNickname != "" %}
<option value={{ item.playerNumber }}>{{ item.playerNickname }}</option>
{% else %}
<option value={{ item.playerNumber }}>{{ item.playerSurname }}, {{ item.playerForenames }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Dick of the Day</span>
<select class="form-control" name="dotdVote" required>
{% for item in data %}
{% if item.playerNickname != "" %}
<option value={{ item.playerNumber }}>{{ item.playerNickname }}</option>
{% else %}
<option value={{ item.playerNumber }}>{{ item.playerSurname }}, {{ item.playerForenames }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-6">
<div class = "input-group">
<span class = "input-group-addon" id = "basic-addon1">Match comments</span>
<textarea rows = "4" cols = "80" name = "motmComment" form = "motmForm">Optional comments added here</textarea>
</div>
</div>
</div>
<div class = "row">
<h3>Rogues Gallery</h3>
<div class = "col-sm-4">
<h4>Current Man of the Match</h4>
<img src="{{ motmURL }}" height="200"></img>
</div>
<div class = "col-sm-4">
<h4>Current Dick of the Day</h4>
<img src="{{ dotdURL }}" height="200"></img>
</div>
</div>
<button type="submit" class="btn btn-success">Submit</button>
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</form>
</div>
</div>
</dl>
</body>
</html>

View File

@ -1,18 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - MotM and DotD vote *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Player removed from matchday squad</h2>
<body>
Player number {{ number }} has been removed from the matchday squad.
<br/>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
<a class="btn btn-info" href="/hkfc-d/matchSquadList" role="button">Squad</a>
</body>
</html>

View File

@ -1,56 +0,0 @@
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="chart_div" style="width: 1600px; height: 1000px;"></div>
<script type="text/javascript">
google.charts.load('current', {
packages: ['corechart']
}).then(function () {
// create chart
var container = $('#chart_div').get(0);
var chart = new google.visualization.ColumnChart(container);
var options = {
legend: {
position: 'top'
}
};
// create data table
var data = new google.visualization.DataTable();
data.addColumn('string', 'Player');
data.addColumn('number', 'MotM');
data.addColumn('number', 'DotD');
// get data
$.ajax({
url: 'poty-results',
dataType: 'json'
}).done(function (jsonData) {
loadData(jsonData);
}).fail(function (jqXHR, textStatus, errorThrown) {
var jsonData = [{"motm_{{ _matchDate }}": 1, "playerName": "ERVINE Jonathan Desmond", "dotd_{{ _matchDate }}": 0}, {"motm_{{ _matchDate }}": 0, "playerName": "MCDONAGH Jerome Michael", "dotd_{{ _matchDate }}": 1}];
loadData(jsonData);
});
// load json data
function loadData(jsonData) {
$.each(jsonData, function(index, row) {
data.addRow([
row.playerName,
row.motmTotal,
row.dotdTotal
]);
});
drawChart();
}
// draw chart
$(window).resize(drawChart);
function drawChart() {
chart.draw(data, options);
}
});
</script>

View File

@ -1,56 +0,0 @@
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="chart_div" style="width: 800px; height: 1000px;"></div>
<script type="text/javascript">
google.charts.load('current', {
packages: ['corechart']
}).then(function () {
// create chart
var container = $('#chart_div').get(0);
var chart = new google.visualization.ColumnChart(container);
var options = {
legend: {
position: 'top'
}
};
// create data table
var data = new google.visualization.DataTable();
data.addColumn('string', 'Player');
data.addColumn('number', 'MotM');
data.addColumn('number', 'DotD');
// get data
$.ajax({
url: 'vote-results',
dataType: 'json'
}).done(function (jsonData) {
loadData(jsonData);
}).fail(function (jqXHR, textStatus, errorThrown) {
var jsonData = [{"motm_{{ _matchDate }}": 1, "playerName": "ERVINE Jonathan Desmond", "dotd_{{ _matchDate }}": 0}, {"motm_{{ _matchDate }}": 0, "playerName": "MCDONAGH Jerome Michael", "dotd_{{ _matchDate }}": 1}];
loadData(jsonData);
});
// load json data
function loadData(jsonData) {
$.each(jsonData, function(index, row) {
data.addRow([
row.playerName,
row.motm_{{ _matchDate }},
row.dotd_{{ _matchDate }}
]);
});
drawChart();
}
// draw chart
$(window).resize(drawChart);
function drawChart() {
chart.draw(data, options);
}
});
</script>

View File

@ -1,19 +0,0 @@
<html>
<head>
<title>HKFC Men's D Team - MotM and DotD vote *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Thanks for submitting the MotM and DotD votes</h2>
<body>
Smithers' army of Internet monkeys will now go about adding up the votes ...
<p>
<img src="https://storage.googleapis.com/hk-hockey-data/images/monkey-typing-simpsons.jpg"></img>
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
<a class="btn btn-info" href="/hkfc-d/comments" role="button">Comments</a>
</body>
</html>

View File

@ -1,17 +0,0 @@
<html>
<head>
<title>HKFC Convenor - Player Record Deletion</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Player Deleted from database</h2>
<body>
Player number {{ number }} has been removed from the player database.
<br/>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>
</html>

View File

@ -1,34 +0,0 @@
<doctype html>
<head>
<title>Match Details - Python Flask MySQL CRUD</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-striped table-hover table-condensed">
{{ matchTable }}
</table>
<h3>Home Team</h3>
<table class="table table-striped table-hover table-condensed">
{{ homeTable }}
</table>
<h3>Away Team</h3>
<table class="table table-striped table-hover table-condensed">
{{ awayTable }}
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,70 +0,0 @@
<html>
<head>
<title>Player Check *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Search Parameters - select a club to search for players who have played for 2 or more teams</h2>
<body onload="myFunction()">
<dl>
<p>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/playerCheckResults">
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Season data to search:</span>
{{ form.season(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Club:</span>
{{ form.clubName(class_="form-control") }}
</div>
</div>
</div>
<p>
{{ form.submitButton(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</p>
</form>
<div class="col-sm-0">
<img src="{{ selectedClubLogo }}" height="120" id="selectedClubLogo"/>
</div>
</div>
</div>
</p>
</dl>
<script>
var club_select = document.getElementById("clubName");
var club_logo = document.getElementById("selectedClubLogo");
club_select.onchange = function() {myFunction()};
function myFunction() {
club = club_select.value;
fetch('/hkfc-d/getLogo/' + club).then(function(response) {
response.json().then(function(data) {
var HTML = '';
for (var logo of data) {
HTML += logo.logoURL;
}
club_logo.src = HTML;
})
});
}
</script>
</body>
</html>

View File

@ -1,41 +0,0 @@
<ooctype html>
<head>
<title>List of player team appearances from 2018/19 season - Python Flask MySQL app</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
{%- for column in columns %}
<th>{{ column['Field'] }}</th>
{%- endfor %}
</thead>
<tbody>
{%- for row in rows %}
<tr>
{%- for column in columns %}
<td>{{ row[column['Field']] }}</td>
{%- endfor %}
</tr>
{%- endfor %}
</tbody>
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,90 +0,0 @@
<doctype html>
<head>
<title>List of players from 2018/19 season - Python Flask MySQL app</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<style>
tbody td {
border: 1px solid #ccc;
padding: 0px 0px;
}
th.rotate {
/* Something you can count on */
height: 120px;
white-space: nowrap;
}
th.rotate > div {
transform:
/* Magic Numbers */
translate(23px, 0px)
/* 45 is really 360 - 45 */
rotate(315deg);
width: 30px;
}
th.rotate > div > span {
border-bottom: 1px solid #ccc;
padding: 0px 0px;
}
</style>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-striped table-hover table-condensed">
<thead>
{%- for column in columns %}
{% if column['Field'] == "playerNumber" %}
<th><div><span>Player Number</span></div></th>
{% elif column['Field'] == "playerName" %}
<th><div><span>Player Name</span></div></th>
{% elif column['Field'] == "appearances" %}
<th><div><span>Appearances</span></div></th>
{% elif column['Field'] == "goals" %}
<th><div><span>Goals</span></div></th>
{% elif column['Field'].startswith('22381goal') %}
<th class="rotate"><div><span>NBC A goals</span></div></th>
{% else %}
{%- for match in matchesList %}
{% if column['Field'].startswith(match) %}
{% if column['Field'].endswith('played') %}
<th class="rotate"><div><span>{{ matches[match] }} Played</span></div></th>
{% elif column['Field'].endswith('goals') %}
<th class="rotate"><div><span>{{ matches[match] }} Goals</span></div></th>
{% elif column['Field'].endswith('capt') %}
<th class="rotate"><div><span>{{ matches[match] }} Captain</span></div></th>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{%- endfor %}
</thead>
<tbody>
{%- for row in rows %}
<tr>
{%- for column in columns %}
<td>{{ row[column['Field']] }}</td>
{%- endfor %}
</tr>
{%- endfor %}
</tbody>
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,87 +0,0 @@
<html>
<head>
<title>Player Playing Record Results Search *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Search Parameters - select both a club and team</h2>
<body onload="myFunction()">
<dl>
<p>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/playerRecordSearch">
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Season data to search:</span>
{{ form.season(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Club:</span>
{{ form.clubName(class_="form-control") }}
</div>
</div>
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Team:</span>
{{ form.teamName(class_="form-control") }}
</div>
</div>
</div>
<p>
{{ form.submitButton(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</p>
</form>
<div class="col-sm-0">
<img src="{{ selectedClubLogo }}" height="120" id="selectedClubLogo"/>
</div>
</div>
</div>
</p>
</dl>
<script>
var club_select = document.getElementById("clubName");
var club_logo = document.getElementById("selectedClubLogo");
var team_select = document.getElementById("teamName");
club_select.onchange = function() {myFunction()};
function myFunction() {
club = club_select.value;
fetch('/hkfc-d/motmAdmin/' + club).then(function(response) {
response.json().then(function(data) {
var optionHTML = '';
for (var team of data) {
optionHTML += '<option value="' + team.team + '">' + team.team + '</option>';
}
team_select.innerHTML = optionHTML;
})
});
fetch('/hkfc-d/getLogo/' + club).then(function(response) {
response.json().then(function(data) {
var HTML = '';
for (var logo of data) {
HTML += logo.logoURL;
}
club_logo.src = HTML;
})
});
}
</script>
</body>
</html>

View File

@ -1,105 +0,0 @@
<html>
<head>
<title>Deployment Selection *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Select a namespace and a deployment</h2>
<body onload="myFunction()">
<dl>
<p>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/get_namespace">
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Namespace:</span>
{{ form.season(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Deployment:</span>
{{ form.clubName(class_="form-control") }}
</div>
</div>
<p>
{{ form.submitButton(class_="btn btn-success") }}
<a class="btn btn-danger" href="/" role="button">Cancel</a>
</p>
</form>
</div>
</div>
</p>
</dl>
<script>
var season_select = document.getElementById("season");
var season_start = document.getElementById("startDate");
var club_select = document.getElementById("clubName");
var club_logo = document.getElementById("selectedClubLogo");
var team_select = document.getElementById("teamName");
season_select.onchange = function() {seasonFunction()};
club_select.onchange = function() {myFunction()};
function myFunction() {
club = club_select.value;
fetch('/hkfc-d/motmAdmin/' + club).then(function(response) {
response.json().then(function(data) {
var optionHTML = '';
for (var team of data) {
optionHTML += '<option value="' + team.team + '">' + team.team + '</option>';
}
team_select.innerHTML = optionHTML;
})
});
fetch('/hkfc-d/getLogo/' + club).then(function(response) {
response.json().then(function(data) {
var HTML = '';
for (var logo of data) {
HTML += logo.logoURL;
}
club_logo.src = HTML;
})
});
}
function seasonFunction() {
season = season_select.value;
var startDate = '';
if (season == '2018') {
startDate = '2018-09-01'
} else if (season == '2017') {
startDate = '2017-01-09'
} else if (season == '2016') {
startDate = '2016-09-01'
} else if (season == '2015') {
startDate = '2015-09-01'
} else if (season == '2014') {
startDate = '2014-09-01'
} else if (season == '2013') {
startDate = '2013-09-01'
} else if (season == '2012') {
startDate = '2012-09-01'
} else if (season == '2011') {
startDate = '2011-09-01'
} else if (season == '2010') {
startDate = '2010-09-01'
}
season_start.value = startDate;
}
</script>
</body>
</html>

View File

@ -1,26 +0,0 @@
<doctype html>
<head>
<title>List of matches from 2018/19 season - Python Flask MySQL CRUD</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-striped table-hover table-condensed">
{{ table }}
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,26 +0,0 @@
<doctype html>
<head>
<title>Team Results from 2018/19 season - Python Flask MySQL app</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-bordered table-striped table-hover table-condensed">
{{ table }}
</table>
<a class="btn btn-primary" href="/dashboard" role="button">Home</a>
</body>

View File

@ -1,85 +0,0 @@
<html>
<head>
<title>Team Results Record Search *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Search Parameters - select both a club and team</h2>
<body onload="myFunction()">
<dl>
<p>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/teamRecordSearch">
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Season data to search:</span>
{{ form.season(class_="form-control") }}
</div>
</div>
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Club:</span>
{{ form.clubName(class_="form-control") }}
</div>
</div>
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">Team:</span>
{{ form.teamName(class_="form-control") }}
</div>
</div>
</div>
<p>
{{ form.submitButton(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</p>
</form>
<div class="col-sm-0">
<img src="{{ selectedClubLogo }}" height="120" id="selectedClubLogo"/>
</div>
</div>
</div>
</p>
</dl>
<script>
var club_select = document.getElementById("clubName");
var club_logo = document.getElementById("selectedClubLogo");
var team_select = document.getElementById("teamName");
club_select.onchange = function() {myFunction()};
function myFunction() {
club = club_select.value;
fetch('/hkfc-d/motmAdmin/' + club).then(function(response) {
response.json().then(function(data) {
var optionHTML = '';
for (var team of data) {
optionHTML += '<option value="' + team.team + '">' + team.team + '</option>';
}
team_select.innerHTML = optionHTML;
})
});
fetch('/hkfc-d/getLogo/' + club).then(function(response) {
response.json().then(function(data) {
var HTML = '';
for (var logo of data) {
HTML += logo.logoURL;
}
club_logo.src = HTML;
})
});
}
</script>
</body>
</html>

View File

@ -1,69 +0,0 @@
{% extends "bootstrap/base.html" %}
{% block title %}
Dashboard
{% endblock %}
{% block head %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/static/css/dashboard.css">
{% endblock %}
{% block body %}
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="dropdown">
<button class="dropbtn">Men's Hockey
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="/search">General Match Search</a>
<a href="/playerRecords">Player Record Search</a>
<a href="/teamRecords">Team Record Search</a>
<a href="/clubPlayingRecords">Club Player Playing Record</a>
<a href="/playerCheck">Played for multiple teams</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">HKFC D
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="/hkfc-d/matchSquad">HKFC D Match Day Squad Selection</a>
<a href="/hkfc-d/matchSquadList">HKFC D Match Day Squad List</a>
<a href="/hkfc-d/matchSquadReset">HKFC D Match Day Squad Reset</a>
<a href="/hkfc-d/motm">MotM and DotD Vote</a>
<a href="/hkfc-d/motmAdmin">MotM and DotD Vote Admin</a>
<a href="/hkfc-d/voting">MotM and DotD Vote Results</a>
<a href="/hkfc-d/comments">HKFC D Match Comments</a>
<a href="/hkfc-d/statAdmin">HKFC Match Stats Admin</a>
<a href="/hkfc-d/fixtureList">Fixture List</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Convenor Area
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="/convenor/clubList">List Clubs and Teams in Club Database</a>
<a href="/convenor/clubAdd">Add Club to Club Database</a>
<a href="/convenor/teamAdd">Add Team to HKFC Database</a>
<a href="/convenor/playerDbCreate">Create Club Player Database</a>
<a href="/convenor/playerAdd">Add Player to Club Database</a>
<a href="/convenor/squadList">Submitted Squad List</a>
<a href="/convenor/fixtureList">Fixture List</a>
<a href="/convenor/other">Other Stuff to be added</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">About
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="/about">About</a>
</div>
</div>
</div>
<h3>Dropdown Menu inside a Navigation Bar</h3>
<p>Hover over the "Dropdown" link to see the dropdown menu.</p>
{% endblock %}

View File

@ -1,68 +1,63 @@
<html>
<head>
<title>Club Player Playing Record Search *TESTING*</title>
<title>Select Namespace and Deployment *TESTING*</title>
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<h2>Search Parameters - select a club to search their playing record</h2>
<h2>Select both a namespace and deployment</h2>
<body onload="myFunction()">
<dl>
<p>
{{ form.csrf_token }}
<div class="row">
<div class="col-xs-12">
<form class="col-sm-6" method="post" action="/clubPlayingRecordSearch">
<form class="col-sm-6" method="post" action="/deploySelect">
<div class = "row">
<div class = "col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Season data to search:</span>
{{ form.season(class_="form-control") }}
<span class="input-group-addon" id="basic-addon1">Namespace:</span>
{{ form.namespace(class_="form-control") }}
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-6">
<div class = "col-sm-4">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Club:</span>
{{ form.clubName(class_="form-control") }}
<span class="input-group-addon" id="basic-addon2">Deployment:</span>
{{ form.deployment(class_="form-control") }}
</div>
</div>
</div>
<p>
{{ form.submitButton(class_="btn btn-success") }}
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
<a class="btn btn-danger" href="/" role="button">Cancel</a>
</p>
</form>
<div class="col-sm-0">
<img src="{{ selectedClubLogo }}" height="120" id="selectedClubLogo"/>
</div>
</div>
</div>
</p>
</dl>
<script>
var club_select = document.getElementById("clubName");
var club_logo = document.getElementById("selectedClubLogo");
var namespaceSelect = document.getElementById("namespace");
var deploymentSelect = document.getElementById("deployment");
club_select.onchange = function() {myFunction()};
namespaceSelect.onchange = function() {myFunction()};
function myFunction() {
club = club_select.value;
namespace = namespaceSelect.value;
fetch('/hkfc-d/getLogo/' + club).then(function(response) {
fetch('/nsLookup/' + namespace).then(function(response) {
response.json().then(function(data) {
var HTML = '';
for (var logo of data) {
HTML += logo.logoURL;
var optionHTML = '';
for (var deployment of data) {
optionHTML += '<option value="' + deployment.deployment + '">' + deployment.deployment + '</option>';
}
club_logo.src = HTML;
deploymentSelect.innerHTML = optionHTML;
})
});
}
</script>

View File

@ -1,25 +0,0 @@
<doctype html>
<head>
<title>List of matches - Python Flask MySQL CRUD</title>
<link rel="stylesheet" media="screen" href ="static/css/bootstrap.min.css">
<link rel="stylesheet" href="static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
</head>
<body>
<p>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</p>
<table class="table table-bordered">
{{ table }}
</table>
</body>

View File

@ -1,52 +0,0 @@
<html>
<head>
<title>TESTING: Search Parameters - Python Flask Hockey Results Search App</title>
<link rel="stylesheet" media="screen" href ="static/css/bootstrap.min.css">
<link rel="stylesheet" href="static/css/bootstrap-theme.min.css">
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
</head>
<h2>Search Parameters</h2>
<body>
Please select your search parameters - search for both club and team
<form method="post" action="/search-results">
<dl>
<p>
<label for="inputClub">Club:</label>
<select class="form-control" name="inputClub" required>
{% for item in data %}
<option value={{ item.hockeyClub }}>{{ item.hockeyClub }}</option>
{% endfor %}
</select>
</p>
<p>
<label for="inputTeam">Team:</label>
<select class="form-control" name="inputTeam" required>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="F">F</option>
<option value="G">G</option>
<option value="H">H</option>
</select>
</p>
<p>
<label for="startDate">Start Date:</label>
<p/>
<input type="date" name="startDate" data-date-format="DD-MM-YYYY"/>
<p/>
<label for="endDate">End Date:</label>
<p/>
<input type="date" name="endDate" data-date-format="DD-MM-YYYY"/>
</p>
</dl>
<p>
<button type="submit" class="btn btn-success">Submit</button>
<a class="btn btn-danger" href="/dashboard" role="button">Cancel</a>
</p>
</form>
</body>
</html>