#import MySQLdb import pymysql import os from app import app from flask_wtf import FlaskForm from wtforms import BooleanField, StringField, PasswordField, IntegerField, TextAreaField, SubmitField, RadioField, SelectField, DateField from wtforms_components import read_only from wtforms import validators, ValidationError from wtforms.validators import InputRequired, Email, Length from readSettings import mySettings from flask_bootstrap import Bootstrap from datetime import datetime #from dbWrite import read_cloudsql, sql_read, sql_read_static class LoginForm(FlaskForm): username = StringField('username', validators=[InputRequired(), Length(min=4, max=15)]) password = PasswordField('password', validators=[InputRequired(), Length(min=4, max=80)]) remember = BooleanField('remember me') class RegisterForm(FlaskForm): email = StringField('email', validators=[InputRequired(), Email(message='Invalid email'), Length(max=50)]) username = StringField('username', validators=[InputRequired(), Length(min=4, max=15)]) password = PasswordField('password', validators=[InputRequired(), Length(min=8, max=80)]) class addPlayerForm(FlaskForm): playerClub = SelectField('Club:', choices=[]) playerTeam = SelectField('Team:', choices=[]) playerForenames = StringField('Forenames:') playerSurnames = StringField('Surname:') playerNickname = StringField('Nickname') playerChineseName = StringField('Chinese Name:') playerEmailAddress = StringField('Email Address:') playerDob = DateField('Date of Birth:', default=datetime.today, format='%Y-%m-%d') playerHkid = StringField('HKID Number:') playerNumber = StringField('Shirt Number:') playerTelNumber = StringField('Player Contact Number:') submit = SubmitField('Submit') class addTeamForm(FlaskForm): clubName = SelectField("Club of team entry to create", coerce=str) teamName = StringField("Team table to create (e.g. A, B, C, etc.)", validators=[InputRequired(), Length(max=1)]) submit = SubmitField("Submit") class addClubForm(FlaskForm): clubName = StringField("Name of the Hockey Club to add") submit = SubmitField("Submit") class playerDbCreateForm(FlaskForm): clubName = SelectField("Name of the Hockey Club to create player database for") year = SelectField("Season start year") submit = SubmitField("Submit") class searchForm(FlaskForm): seasonStart = datetime.strptime('2018-09-01', '%Y-%m-%d') season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')]) clubName = SelectField("Club to search", choices=[], coerce=str) teamName = SelectField("Select a Team", choices=[]) startDate = DateField('DatePicker', format='%Y-%m-%d', default=seasonStart) endDate = DateField('DatePicker', format='%Y-%m-%d', default=datetime.today()) submitButton = SubmitField("Submit") class playerRecordsForm(FlaskForm): season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')]) clubName = SelectField("Club to search", choices=[], coerce=str) teamName = SelectField("Select a Team", choices=[]) submitButton = SubmitField("Submit") class teamRecordsForm(FlaskForm): season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')]) clubName = SelectField("Club to search", choices=[], coerce=str) teamName = SelectField("Select a Team", choices=[]) submitButton = SubmitField("Submit") class clubPlayingRecordsForm(FlaskForm): season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')]) clubName = SelectField("Club to search", choices=[], coerce=str) submitButton = SubmitField("Submit") class squadListForm(FlaskForm): teamName = SelectField("HKFC team to display") submit = SubmitField("Submit") class adminSettingsForm(FlaskForm): nextOppoClub = SelectField('Next Opposition Club:', choices=[], default=mySettings('club')) nextOppoTeam = SelectField("Next Opposition Team:", choices=[]) nextMatchDate = DateField('DatePicker', format='%Y-%m-%d', default=mySettings('date')) currMotM = SelectField('Current Man of the Match:', choices=[], default=mySettings('motm')) currDotD = SelectField('Current Dick of the Day:', choices=[], default=mySettings('dotd')) saveButton = SubmitField('Save Settings') activateButton = SubmitField('Activate MotM Vote')