129 lines
5.0 KiB
Python
129 lines
5.0 KiB
Python
# encoding=utf-8
|
|
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 datetime import datetime
|
|
|
|
|
|
class motmForm(FlaskForm):
|
|
startDate = DateField('DatePicker', format='%d-%m-%Y')
|
|
endDate = DateField('DatePicker', format='%d-%m-%Y')
|
|
|
|
|
|
class motmAdminForm(FlaskForm):
|
|
startDate = DateField('DatePicker', format='%d-%m-%Y')
|
|
endDate = DateField('DatePicker', format='%d-%m-%Y')
|
|
|
|
|
|
class adminSettingsForm2(FlaskForm):
|
|
nextMatchDate = DateField('Match Date', format='%Y-%m-%d')
|
|
nextOppoClub = StringField('Next Opposition Club:')
|
|
nextOppoTeam = StringField("Next Opposition Team:")
|
|
currMotM = SelectField('Current Man of the Match:', choices=[])
|
|
currDotD = SelectField('Current Dick of the Day:', choices=[])
|
|
saveButton = SubmitField('Save Settings')
|
|
activateButton = SubmitField('Activate MotM Vote')
|
|
|
|
|
|
class goalsAssistsForm(FlaskForm):
|
|
fixtureNumber = StringField('Fixture Number')
|
|
match = SelectField('Fixture')
|
|
homeTeam = StringField('Home Team')
|
|
awayTeam = StringField('Away Team')
|
|
playerNumber = StringField('Player Number')
|
|
playerName = StringField('Player Name')
|
|
assists = SelectField('Assists:', choices=[(0, '0'), (1, '1'), (2, '2'), (3, '3'), (4, '4')])
|
|
goals = SelectField('Goals:', choices=[(0, '0'), (1, '1'), (2, '2'), (3, '3'), (4, '4')])
|
|
submit = SubmitField('Submit')
|
|
|
|
|
|
class DatabaseSetupForm(FlaskForm):
|
|
"""Form for database setup and configuration."""
|
|
database_type = SelectField('Database Type',
|
|
choices=[('sqlite', 'SQLite'), ('mysql', 'MySQL/MariaDB'), ('postgresql', 'PostgreSQL')],
|
|
validators=[InputRequired()])
|
|
|
|
# SQLite fields
|
|
sqlite_database_path = StringField('Database File Path',
|
|
default='hockey_results.db')
|
|
|
|
# MySQL/MariaDB fields
|
|
mysql_host = StringField('Host', default='localhost')
|
|
mysql_port = IntegerField('Port', default=3306)
|
|
mysql_database = StringField('Database Name', default='hockey_results')
|
|
mysql_username = StringField('Username', default='root')
|
|
mysql_password = PasswordField('Password')
|
|
mysql_charset = StringField('Charset', default='utf8mb4')
|
|
|
|
# PostgreSQL fields
|
|
postgres_host = StringField('Host', default='localhost')
|
|
postgres_port = IntegerField('Port', default=5432)
|
|
postgres_database = StringField('Database Name', default='hockey_results')
|
|
postgres_username = StringField('Username', default='postgres')
|
|
postgres_password = PasswordField('Password')
|
|
|
|
# Setup options
|
|
create_sample_data = BooleanField('Create Sample Data', default=True)
|
|
initialize_tables = BooleanField('Initialize Database Tables', default=True)
|
|
|
|
# Action buttons
|
|
test_connection = SubmitField('Test Connection')
|
|
save_config = SubmitField('Save Configuration')
|
|
initialize_database = SubmitField('Initialize Database')
|
|
|
|
|
|
class PlayerForm(FlaskForm):
|
|
"""Form for adding/editing players."""
|
|
|
|
player_number = IntegerField('Player Number', validators=[InputRequired()])
|
|
player_forenames = StringField('First Names', validators=[InputRequired()])
|
|
player_surname = StringField('Surname', validators=[InputRequired()])
|
|
player_nickname = StringField('Nickname', validators=[InputRequired()])
|
|
player_team = SelectField('Team',
|
|
choices=[('HKFC A', 'HKFC A'),
|
|
('HKFC B', 'HKFC B'),
|
|
('HKFC C', 'HKFC C')],
|
|
default='HKFC C')
|
|
|
|
# Action buttons
|
|
save_player = SubmitField('Save Player')
|
|
cancel = SubmitField('Cancel')
|
|
|
|
|
|
class ClubForm(FlaskForm):
|
|
"""Form for adding/editing clubs."""
|
|
|
|
hockey_club = StringField('Club Name', validators=[InputRequired()])
|
|
logo_url = StringField('Logo URL', validators=[InputRequired()])
|
|
|
|
# Action buttons
|
|
save_club = SubmitField('Save Club')
|
|
cancel = SubmitField('Cancel')
|
|
|
|
|
|
class TeamForm(FlaskForm):
|
|
"""Form for adding/editing teams."""
|
|
|
|
club = StringField('Club', validators=[InputRequired()])
|
|
team = StringField('Team', validators=[InputRequired()])
|
|
display_name = StringField('Display Name', validators=[InputRequired()])
|
|
league = StringField('League', validators=[InputRequired()])
|
|
|
|
# Action buttons
|
|
save_team = SubmitField('Save Team')
|
|
cancel = SubmitField('Cancel')
|
|
|
|
|
|
class DataImportForm(FlaskForm):
|
|
"""Form for importing data from Hong Kong Hockey Association."""
|
|
|
|
import_clubs = BooleanField('Import Clubs', default=True)
|
|
import_teams = BooleanField('Import Teams', default=True)
|
|
import_players = BooleanField('Import Sample Players', default=False)
|
|
|
|
# Action buttons
|
|
import_data = SubmitField('Import Data')
|
|
cancel = SubmitField('Cancel')
|