diff --git a/dbWrite.py b/dbWrite.py
deleted file mode 100644
index f20b81f..0000000
--- a/dbWrite.py
+++ /dev/null
@@ -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
diff --git a/main.py b/main.py
index df3976e..511f8a2 100644
--- a/main.py
+++ b/main.py
@@ -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()
diff --git a/readSettings.py b/readSettings.py
deleted file mode 100644
index 2f49a99..0000000
--- a/readSettings.py
+++ /dev/null
@@ -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
-
diff --git a/routes/__init__.py b/routes/__init__.py
deleted file mode 100644
index 8ed905c..0000000
--- a/routes/__init__.py
+++ /dev/null
@@ -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 *
diff --git a/routes/_convenor.py b/routes/_convenor.py
deleted file mode 100644
index 681f068..0000000
--- a/routes/_convenor.py
+++ /dev/null
@@ -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)
diff --git a/routes/_hkfcD_motm.py b/routes/_hkfcD_motm.py
deleted file mode 100644
index 484fc3e..0000000
--- a/routes/_hkfcD_motm.py
+++ /dev/null
@@ -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/')
-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/')
-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/')
-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/')
-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/')
-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/')
-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)
diff --git a/routes/_matches.py b/routes/_matches.py
deleted file mode 100644
index b193265..0000000
--- a/routes/_matches.py
+++ /dev/null
@@ -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/')
-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)
diff --git a/routes/_search.py b/routes/_search.py
deleted file mode 100644
index 40ee80a..0000000
--- a/routes/_search.py
+++ /dev/null
@@ -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'
diff --git a/routes/dashboard.py b/routes/dashboard.py
deleted file mode 100644
index d607adb..0000000
--- a/routes/dashboard.py
+++ /dev/null
@@ -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')
diff --git a/routes/kube-helm-routes.py b/routes/kube-helm-routes.py
new file mode 100644
index 0000000..ba628bf
--- /dev/null
+++ b/routes/kube-helm-routes.py
@@ -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)
\ No newline at end of file
diff --git a/tables.py b/tables.py
deleted file mode 100644
index 9297c03..0000000
--- a/tables.py
+++ /dev/null
@@ -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')
-
diff --git a/templates/_about.html b/templates/_about.html
deleted file mode 100644
index c0bbde1..0000000
--- a/templates/_about.html
+++ /dev/null
@@ -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
diff --git a/templates/_clubPlayingRecordResults.html b/templates/_clubPlayingRecordResults.html
deleted file mode 100644
index 76bb70e..0000000
--- a/templates/_clubPlayingRecordResults.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
- List of player team appearances from 2018/19 season - Python Flask MySQL app
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
- Home
-
-
- {%- for column in columns %}
- {{ column['Field'] }}
- {%- endfor %}
-
-
-
- {%- for row in rows %}
-
- {%- for column in columns %}
- {{ row[column['Field']] }}
- {%- endfor %}
-
- {%- endfor %}
-
-
- Home
-
diff --git a/templates/_convenorClubAdd.html b/templates/_convenorClubAdd.html
deleted file mode 100644
index d50e556..0000000
--- a/templates/_convenorClubAdd.html
+++ /dev/null
@@ -1,31 +0,0 @@
-{% extends "bootstrap/base.html" %}
-
-{% block title %}
-Add Club Form
-{% endblock %}
-
-{% block head %}
-
-
-
-
-
-{% endblock %}
-
-{% block body %}
-
-
-
-{% endblock %}
-
diff --git a/templates/_convenorClubAddResults.html b/templates/_convenorClubAddResults.html
deleted file mode 100644
index c62e2d7..0000000
--- a/templates/_convenorClubAddResults.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- HKFC Men's D Team - MotM and DotD vote *TESTING*
-
-
-
-
-
-
- Thanks for adding {{ data }} to the club database
-
- This automatically adds the A team of {{ data }} to the database.
-
-
- Home
-
-
-
diff --git a/templates/_convenorClubList.html b/templates/_convenorClubList.html
deleted file mode 100644
index 90ed446..0000000
--- a/templates/_convenorClubList.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- List of Clubs and Teams - Python Flask MySQL CRUD
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
- Home
-
diff --git a/templates/_convenorEditPlayerResults.html b/templates/_convenorEditPlayerResults.html
deleted file mode 100644
index 4acb088..0000000
--- a/templates/_convenorEditPlayerResults.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- *TESTING* Player Added to Database
-
-
-
-
-
-
- Thanks for editting {{ firstname }} {{ surname }} in the {{ club }} database
-
- {{ firstname }} {{ surname }} with shirt number {{ shirt }} has been modified in the {{ club }} database for this season.
-
-
- Home
-
-
-
diff --git a/templates/_convenorEditSquadList.html b/templates/_convenorEditSquadList.html
deleted file mode 100644
index 5be31f8..0000000
--- a/templates/_convenorEditSquadList.html
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
- Edit Team Members
-
-
- Edit Team
-
-
-
diff --git a/templates/_convenorEditSquadListTeamSelect.html b/templates/_convenorEditSquadListTeamSelect.html
deleted file mode 100644
index cd95d4d..0000000
--- a/templates/_convenorEditSquadListTeamSelect.html
+++ /dev/null
@@ -1,35 +0,0 @@
-{% extends "bootstrap/base.html" %}
-
-{% block title %}
-List Team Squad
-{% endblock %}
-
-{% block head %}
-
-
-
-
-
-{% endblock %}
-
-{% block body %}
-
-
-
-{% endblock %}
-
diff --git a/templates/_convenorFixtureList.html b/templates/_convenorFixtureList.html
deleted file mode 100644
index 23d838c..0000000
--- a/templates/_convenorFixtureList.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- Fixture List 2019/20 season
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
- Home
-
diff --git a/templates/_convenorPlayerAdd.html b/templates/_convenorPlayerAdd.html
deleted file mode 100644
index 257e8ac..0000000
--- a/templates/_convenorPlayerAdd.html
+++ /dev/null
@@ -1,158 +0,0 @@
-
-
- HKFC Men's Convenor - Player Add form *TESTING*
-
-
-
-
-
-
- HKFC Men's Convenor Add Player Record Form
- {% with messages = get_flashed_messages() %}
- {% if messages %}
- {% for message in messages %}
-
- ×
- {{ message }}
-
- {% endfor %}
- {% endif %}
- {% endwith %}
-
-
-
- {{ form.csrf_token }}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/_convenorPlayerAddResults.html b/templates/_convenorPlayerAddResults.html
deleted file mode 100644
index 1836a81..0000000
--- a/templates/_convenorPlayerAddResults.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- *TESTING* Player Added to Database
-
-
-
-
-
-
- Thanks for adding {{ firstname }} {{ surname }} to the {{ club }} database
-
- {{ firstname }} {{ surname }} with shirt number {{ shirt }} has been added to the {{ club }} database for this season.
-
-
- Home
-
-
-
diff --git a/templates/_convenorPlayerDbCreate.html b/templates/_convenorPlayerDbCreate.html
deleted file mode 100644
index e6c52f4..0000000
--- a/templates/_convenorPlayerDbCreate.html
+++ /dev/null
@@ -1,36 +0,0 @@
-{% extends "bootstrap/base.html" %}
-
-{% block title %}
-Add Team Table
-{% endblock %}
-
-{% block head %}
-
-
-
-
-
-{% endblock %}
-
-{% block body %}
-
-
-
-{% endblock %}
-
diff --git a/templates/_convenorPlayerDbCreateResults.html b/templates/_convenorPlayerDbCreateResults.html
deleted file mode 100644
index 6ae6894..0000000
--- a/templates/_convenorPlayerDbCreateResults.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- *TESTING* CLub Player DB Creation Results
-
-
-
-
-
-
- Adding {{ club }} player database for season starting {{ year }}
-
- A player database for {{ club }} for the season starting {{ year }} should now exist.
-
-
- Home
-
-
-
diff --git a/templates/_convenorPlayerEdit.html b/templates/_convenorPlayerEdit.html
deleted file mode 100644
index 6e018b6..0000000
--- a/templates/_convenorPlayerEdit.html
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
- HKFC Men's Convenor - Player Add form *TESTING*
-
-
-
-
-
-
- HKFC Men's Convenor Edit Player Record Form
- {% with messages = get_flashed_messages() %}
- {% if messages %}
- {% for message in messages %}
-
- ×
- {{ message }}
-
- {% endfor %}
- {% endif %}
- {% endwith %}
-
- {{ data }}
-
-
- {{ form.csrf_token }}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/_convenorSquadList.html b/templates/_convenorSquadList.html
deleted file mode 100644
index 0e438f8..0000000
--- a/templates/_convenorSquadList.html
+++ /dev/null
@@ -1,35 +0,0 @@
-{% extends "bootstrap/base.html" %}
-
-{% block title %}
-List Team Squad
-{% endblock %}
-
-{% block head %}
-
-
-
-
-
-{% endblock %}
-
-{% block body %}
-
-
-
-{% endblock %}
-
diff --git a/templates/_convenorSquadListResults.html b/templates/_convenorSquadListResults.html
deleted file mode 100644
index ab4949c..0000000
--- a/templates/_convenorSquadListResults.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- List of players from HKFC {{ _team }} Team for 2017/18 season
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
- Home
-
diff --git a/templates/_convenorTeamAdd.html b/templates/_convenorTeamAdd.html
deleted file mode 100644
index 5ce1347..0000000
--- a/templates/_convenorTeamAdd.html
+++ /dev/null
@@ -1,38 +0,0 @@
-{% extends "bootstrap/base.html" %}
-
-{% block title %}
-Add Team Table
-{% endblock %}
-
-{% block head %}
-
-
-
-
-
-{% endblock %}
-
-{% block body %}
-
-
-
-{% endblock %}
-
diff --git a/templates/_convenorTeamAddResults.html b/templates/_convenorTeamAddResults.html
deleted file mode 100644
index 8eb2f37..0000000
--- a/templates/_convenorTeamAddResults.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- *TESTING* - Team Add Results
-
-
-
-
-
-
- Thanks for adding {{ club }} {{ team }} to the club database
-
- {{ club }} {{ team }} should now be added to the database.
-
-
- Home
-
-
-
diff --git a/templates/_error.html b/templates/_error.html
deleted file mode 100644
index 8d7fdea..0000000
--- a/templates/_error.html
+++ /dev/null
@@ -1 +0,0 @@
-Bzzzzt. This is an error.
diff --git a/templates/_goalsAssistsAdmin.html b/templates/_goalsAssistsAdmin.html
deleted file mode 100644
index bac43ee..0000000
--- a/templates/_goalsAssistsAdmin.html
+++ /dev/null
@@ -1,173 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{{ form.csrf_token }}
-
-
-
-
diff --git a/templates/_hkfcDAdminThanks.html b/templates/_hkfcDAdminThanks.html
deleted file mode 100644
index d003882..0000000
--- a/templates/_hkfcDAdminThanks.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- HKFC Men's D Team - MotM and DotD admin *TESTING*
-
-
-
-
-
-
- Thanks for activating the MotM and DotD votes
- Back to the dashboard
-
-
-
diff --git a/templates/_hkfcDGoalsThanks.html b/templates/_hkfcDGoalsThanks.html
deleted file mode 100644
index 94c49c1..0000000
--- a/templates/_hkfcDGoalsThanks.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- HKFC Men's D Team - Goals and Assists
-
-
-
-
-
-
- Thanks for submitting the goals and assists statistics
-
- Smithers' army of Internet monkeys will now go about adding up the numbers ...
-
-
-
- Home
-
-
diff --git a/templates/_hkfcDMatchComments.html b/templates/_hkfcDMatchComments.html
deleted file mode 100644
index afc0d1b..0000000
--- a/templates/_hkfcDMatchComments.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- HKFC Men's D Team - Match Comments *TESTING*
-
-
-
-
-
-
- HKFC Men's D Team Match Comments
- 16th December 2018 - Aquila A
- V
-
- This is an experimental option to add comments on the match - all submitted comments should appear here
-
- The wit and wisdom of the HKFC D team (in random order):
-
- {% for item in comments %}
- {{ item.comment }}
-
-
- {% else %}
- No comments have been submitted yet.
- {% endfor %}
-
-
-
diff --git a/templates/_hkfcDMatchSquad.html b/templates/_hkfcDMatchSquad.html
deleted file mode 100644
index 81570d6..0000000
--- a/templates/_hkfcDMatchSquad.html
+++ /dev/null
@@ -1,200 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/_hkfcDMatchSquadReset.html b/templates/_hkfcDMatchSquadReset.html
deleted file mode 100644
index 61ca02b..0000000
--- a/templates/_hkfcDMatchSquadReset.html
+++ /dev/null
@@ -1,3 +0,0 @@
-The table for the HKFC D team has been deleted and recreated (empty)
-
-Home
diff --git a/templates/_hkfcDMatchSquadSelected.html b/templates/_hkfcDMatchSquadSelected.html
deleted file mode 100644
index ab4949c..0000000
--- a/templates/_hkfcDMatchSquadSelected.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- List of players from HKFC {{ _team }} Team for 2017/18 season
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
- Home
-
diff --git a/templates/_hkfcDMotmAdmin.html b/templates/_hkfcDMotmAdmin.html
deleted file mode 100644
index 0ab0d8c..0000000
--- a/templates/_hkfcDMotmAdmin.html
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
- HKFC Men's D Team - MotM and DotD vote admin *TESTING*
-
-
-
-
-
-
- HKFC Men's D Team MotM and DotD online vote admin page
- {% with messages = get_flashed_messages() %}
- {% if messages %}
- {% for message in messages %}
-
- ×
- {{ message }}
-
- {% endfor %}
- {% endif %}
- {% endwith %}
-
-
-
-
- {{ form.csrf_token }}
- HKFC D Next Opponent:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/_hkfcDMotmVote.html b/templates/_hkfcDMotmVote.html
deleted file mode 100644
index 8b19490..0000000
--- a/templates/_hkfcDMotmVote.html
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
- HKFC Men's D Team - MotM and DotD online vote *TESTING*
-
-
-
-
-
-
- HKFC Men's D Team MotM and DotD online vote
- {{ formatDate }}
-
-
- Randomly selected comment from the match:
-
- {% for item in comment %}
- {{ item.comment }}
- {% endfor %}
-
-
- {{ form.csrf_token }}
-
-
-
-
diff --git a/templates/_hkfcDPlayerRemoved.html b/templates/_hkfcDPlayerRemoved.html
deleted file mode 100644
index 5f5d279..0000000
--- a/templates/_hkfcDPlayerRemoved.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- HKFC Men's D Team - MotM and DotD vote *TESTING*
-
-
-
-
-
-
- Player removed from matchday squad
-
- Player number {{ number }} has been removed from the matchday squad.
-
- Home
- Squad
-
-
-
diff --git a/templates/_hkfcDPotYChart.html b/templates/_hkfcDPotYChart.html
deleted file mode 100644
index 47e66f3..0000000
--- a/templates/_hkfcDPotYChart.html
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
diff --git a/templates/_hkfcDVoteChart.html b/templates/_hkfcDVoteChart.html
deleted file mode 100644
index 5af3267..0000000
--- a/templates/_hkfcDVoteChart.html
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
diff --git a/templates/_hkfcDVoteThanks.html b/templates/_hkfcDVoteThanks.html
deleted file mode 100644
index 671bc01..0000000
--- a/templates/_hkfcDVoteThanks.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
- HKFC Men's D Team - MotM and DotD vote *TESTING*
-
-
-
-
-
-
- Thanks for submitting the MotM and DotD votes
-
- Smithers' army of Internet monkeys will now go about adding up the votes ...
-
-
-
- Home
- Comments
-
-
diff --git a/templates/_hkfcPlayerDeleted.html b/templates/_hkfcPlayerDeleted.html
deleted file mode 100644
index c733af7..0000000
--- a/templates/_hkfcPlayerDeleted.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- HKFC Convenor - Player Record Deletion
-
-
-
-
-
-
- Player Deleted from database
-
- Player number {{ number }} has been removed from the player database.
-
- Home
-
-
-
diff --git a/templates/_matchDetails.html b/templates/_matchDetails.html
deleted file mode 100644
index d305ae6..0000000
--- a/templates/_matchDetails.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
- Match Details - Python Flask MySQL CRUD
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
- Home Team
-
- Away Team
-
- Home
-
diff --git a/templates/_playerCheck.html b/templates/_playerCheck.html
deleted file mode 100644
index 1a883bd..0000000
--- a/templates/_playerCheck.html
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
- Player Check *TESTING*
-
-
-
-
-
-
- Search Parameters - select a club to search for players who have played for 2 or more teams
-
-
-
- {{ form.csrf_token }}
-
-
-
-
-
-
- Season data to search:
- {{ form.season(class_="form-control") }}
-
-
-
-
-
-
- Club:
- {{ form.clubName(class_="form-control") }}
-
-
-
-
- {{ form.submitButton(class_="btn btn-success") }}
- Cancel
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/_playerCheckResults.html b/templates/_playerCheckResults.html
deleted file mode 100644
index 76bb70e..0000000
--- a/templates/_playerCheckResults.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
- List of player team appearances from 2018/19 season - Python Flask MySQL app
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
- Home
-
-
- {%- for column in columns %}
- {{ column['Field'] }}
- {%- endfor %}
-
-
-
- {%- for row in rows %}
-
- {%- for column in columns %}
- {{ row[column['Field']] }}
- {%- endfor %}
-
- {%- endfor %}
-
-
- Home
-
diff --git a/templates/_playerRecordResults.html b/templates/_playerRecordResults.html
deleted file mode 100644
index ad6eba5..0000000
--- a/templates/_playerRecordResults.html
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
- List of players from 2018/19 season - Python Flask MySQL app
-
-
-
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
-
- {%- for column in columns %}
- {% if column['Field'] == "playerNumber" %}
- Player Number
- {% elif column['Field'] == "playerName" %}
- Player Name
- {% elif column['Field'] == "appearances" %}
- Appearances
- {% elif column['Field'] == "goals" %}
- Goals
- {% elif column['Field'].startswith('22381goal') %}
- NBC A goals
- {% else %}
- {%- for match in matchesList %}
- {% if column['Field'].startswith(match) %}
- {% if column['Field'].endswith('played') %}
- {{ matches[match] }} Played
- {% elif column['Field'].endswith('goals') %}
- {{ matches[match] }} Goals
- {% elif column['Field'].endswith('capt') %}
- {{ matches[match] }} Captain
- {% endif %}
- {% endif %}
- {% endfor %}
- {% endif %}
- {%- endfor %}
-
-
-
- {%- for row in rows %}
-
- {%- for column in columns %}
- {{ row[column['Field']] }}
- {%- endfor %}
-
- {%- endfor %}
-
-
- Home
-
-
diff --git a/templates/_playerRecords.html b/templates/_playerRecords.html
deleted file mode 100644
index 265b5c9..0000000
--- a/templates/_playerRecords.html
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
- Player Playing Record Results Search *TESTING*
-
-
-
-
-
-
- Search Parameters - select both a club and team
-
-
-
- {{ form.csrf_token }}
-
-
-
-
-
-
- Season data to search:
- {{ form.season(class_="form-control") }}
-
-
-
-
-
-
- Club:
- {{ form.clubName(class_="form-control") }}
-
-
-
-
- Team:
- {{ form.teamName(class_="form-control") }}
-
-
-
-
- {{ form.submitButton(class_="btn btn-success") }}
- Cancel
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/_search.html b/templates/_search.html
deleted file mode 100644
index 4337423..0000000
--- a/templates/_search.html
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
- Deployment Selection *TESTING*
-
-
-
-
-
-
- Select a namespace and a deployment
-
-
-
- {{ form.csrf_token }}
-
-
-
-
-
-
- Namespace:
- {{ form.season(class_="form-control") }}
-
-
-
-
-
-
- Deployment:
- {{ form.clubName(class_="form-control") }}
-
-
-
- {{ form.submitButton(class_="btn btn-success") }}
- Cancel
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/_searchResults.html b/templates/_searchResults.html
deleted file mode 100644
index 5b20ab5..0000000
--- a/templates/_searchResults.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- List of matches from 2018/19 season - Python Flask MySQL CRUD
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
- Home
-
diff --git a/templates/_teamRecordResults.html b/templates/_teamRecordResults.html
deleted file mode 100644
index f381b17..0000000
--- a/templates/_teamRecordResults.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- Team Results from 2018/19 season - Python Flask MySQL app
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
- Home
-
diff --git a/templates/_teamRecords.html b/templates/_teamRecords.html
deleted file mode 100644
index b2214d4..0000000
--- a/templates/_teamRecords.html
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
- Team Results Record Search *TESTING*
-
-
-
-
-
-
- Search Parameters - select both a club and team
-
-
-
- {{ form.csrf_token }}
-
-
-
-
-
-
- Season data to search:
- {{ form.season(class_="form-control") }}
-
-
-
-
- Club:
- {{ form.clubName(class_="form-control") }}
-
-
-
-
- Team:
- {{ form.teamName(class_="form-control") }}
-
-
-
-
- {{ form.submitButton(class_="btn btn-success") }}
- Cancel
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/templates/dashboard.html b/templates/dashboard.html
deleted file mode 100644
index b9e4df6..0000000
--- a/templates/dashboard.html
+++ /dev/null
@@ -1,69 +0,0 @@
-{% extends "bootstrap/base.html" %}
-
-{% block title %}
-Dashboard
-{% endblock %}
-
-{% block head %}
-
-
-
-{% endblock %}
-
-{% block body %}
-
-Dropdown Menu inside a Navigation Bar
-Hover over the "Dropdown" link to see the dropdown menu.
-{% endblock %}
diff --git a/templates/_clubPlayingRecords.html b/templates/nameDeploySelect.html
similarity index 53%
rename from templates/_clubPlayingRecords.html
rename to templates/nameDeploySelect.html
index d4d8640..67fdf94 100644
--- a/templates/_clubPlayingRecords.html
+++ b/templates/nameDeploySelect.html
@@ -1,68 +1,63 @@
- Club Player Playing Record Search *TESTING*
+ Select Namespace and Deployment *TESTING*
- Search Parameters - select a club to search their playing record
+ Select both a namespace and deployment
{{ form.csrf_token }}
-
+
- Season data to search:
- {{ form.season(class_="form-control") }}
+ Namespace:
+ {{ form.namespace(class_="form-control") }}
-
-
-
+
- Club:
- {{ form.clubName(class_="form-control") }}
+ Deployment:
+ {{ form.deployment(class_="form-control") }}
{{ form.submitButton(class_="btn btn-success") }}
- Cancel
+ Cancel
-
-
-
diff --git a/templates/results.html b/templates/results.html
deleted file mode 100644
index 03a4e11..0000000
--- a/templates/results.html
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- List of matches - Python Flask MySQL CRUD
-
-
-
-
-
-
-
-
- {% with messages = get_flashed_messages() %}
- {% if messages %}
-
- {% for message in messages %}
- {{ message }}
- {% endfor %}
-
- {% endif %}
- {% endwith %}
-
-
-
diff --git a/templates/search.html b/templates/search.html
deleted file mode 100644
index 2d9f534..0000000
--- a/templates/search.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
- TESTING: Search Parameters - Python Flask Hockey Results Search App
-
-
-
-
-
-
- Search Parameters
-
- Please select your search parameters - search for both club and team
-
-
-
- Club:
-
- {% for item in data %}
- {{ item.hockeyClub }}
- {% endfor %}
-
-
-
- Team:
-
- A
- B
- C
- D
- E
- F
- G
- H
-
-
-
- Start Date:
-
-
-
- End Date:
-
-
-
-
-
- Submit
- Cancel
-
-
-
-