| .. | ||
| static | ||
| templates | ||
| .gitignore | ||
| activate_motm.bat | ||
| activate_motm.sh | ||
| alembic.ini | ||
| app.py | ||
| app.yaml | ||
| Containerfile | ||
| database_config.ini | ||
| database.py | ||
| db_config.py | ||
| db_setup.py | ||
| deploy.py | ||
| forms.py | ||
| main.py | ||
| README.md | ||
| readSettings.py | ||
| requirements.txt | ||
| run_motm.bat | ||
| run_motm.sh | ||
| SETUP_GUIDE.md | ||
| setup_venv_windows.bat | ||
| setup_venv.ps1 | ||
| setup_venv.py | ||
| tables.py | ||
| test_app.py | ||
| VIRTUAL_ENV_GUIDE.md | ||
HKFC Men's C Team - MOTM (Man of the Match) System
This is a standalone Flask application for managing Man of the Match and Dick of the Day voting for the HKFC Men's C Team hockey club.
Features
Public Section
- Voting Interface: Players can vote for MOTM and DotD via secure random URLs
- Match Comments: View and add comments from matches
- Current Holders: Display current MOTM and DotD holders
Admin Section
- Match Management: Set up upcoming matches, opposition teams, and fixtures
- Squad Management: Add/remove players from match squads
- Statistics: Record goals and assists for players
- Voting Results: View real-time voting charts and results
- Player of the Year: Track season-long MOTM/DotD statistics
Installation
Option 1: Using Virtual Environment (Recommended)
Windows Setup:
- Create virtual environment:
python -m venv venv
If python doesn't work, try py or use the full path to python.exe
- Activate virtual environment:
venv\Scripts\activate.bat
- Install dependencies:
pip install --upgrade pip
pip install -r requirements.txt
- Run the application:
python main.py
Unix/Linux/Mac Setup:
- Create virtual environment:
python3 -m venv venv
- Activate virtual environment:
source venv/bin/activate
- Install dependencies:
pip install --upgrade pip
pip install -r requirements.txt
- Run the application:
python main.py
Convenience Scripts:
- After setup, you can use
activate_motm.bat(Windows) orsource activate_motm.sh(Unix) - Or use
run_motm.bat(Windows) or./run_motm.sh(Unix) to start directly
Option 2: Manual Virtual Environment Setup
- Create virtual environment:
python -m venv venv
-
Activate virtual environment:
- Windows:
venv\Scripts\activate - Unix/Linux/Mac:
source venv/bin/activate
- Windows:
-
Install dependencies:
pip install -r requirements.txt
-
Configure database settings in
db_config.py -
Run the application:
python main.py
Option 3: Global Installation (Not Recommended)
- Install dependencies:
pip install -r requirements.txt
-
Configure database settings in
db_config.py -
Run the application:
python main.py
The application will be available at http://localhost:5000
Database Requirements
The application requires access to the following database tables:
_hkfcC_matchSquad- Current match squad_HKFC_players- Player databasehkfcCAdminSettings- Admin configurationhockeyFixtures- Match fixtures_hkfc_c_motm- MOTM/DotD voting results_motmComments- Match comments_clubTeams- Club and team informationmensHockeyClubs- Club logos and information
API Endpoints
Public Endpoints
/- Main index page/motm/<randomUrlSuffix>- Voting page (requires valid URL suffix)/motm/comments- Match comments/motm/vote-thanks- Vote submission processing
Admin Endpoints (Basic Auth Required)
/admin/motm- MOTM administration/admin/squad- Squad management/admin/squad/submit- Process squad selection/admin/squad/list- View current squad/admin/squad/remove- Remove player from squad/admin/squad/reset- Reset squad for new match/admin/stats- Goals and assists administration/admin/voting- Voting results charts/admin/poty- Player of the Year charts
API Endpoints
/api/vote-results- Get voting results as JSON/api/poty-results- Get Player of the Year results as JSON/admin/api/team/<club>- Get teams for a club/admin/api/logo/<club>- Get club logo URL/admin/api/fixture/<fixture>- Get fixture information
Security
- Admin sections are protected with HTTP Basic Authentication
- Voting URLs use random suffixes to prevent unauthorized access
- All admin actions require authentication
Usage
-
Admin Setup:
- Access
/admin/motmto configure upcoming matches - Use
/admin/squadto select players for the match - Activate voting to generate the public voting URL
- Access
-
Player Voting:
- Share the generated voting URL with players
- Players can vote for MOTM and DotD
- Optional comments can be added
-
Results:
- View real-time results at
/admin/voting - Track season statistics at
/admin/poty
- View real-time results at
Configuration
Update the following in db_config.py:
- Database connection details
- Cloud SQL configuration (if using Google Cloud)
- Local database settings
The application uses the same database as the main hockey results system, so ensure proper database access is configured.
Virtual Environment Management
Development Workflow
-
Activate virtual environment before making changes:
- Windows:
activate_motm.batorvenv\Scripts\activate - Unix/Linux/Mac:
source activate_motm.shorsource venv/bin/activate
- Windows:
-
Install new packages:
pip install new-package-name
- Update requirements.txt after adding packages:
pip freeze > requirements.txt
- Deactivate when done:
deactivate
Virtual Environment Benefits
- Isolation: Dependencies won't conflict with other Python projects
- Version Control: Pin specific package versions for reproducibility
- Clean Environment: Easy to recreate if corrupted
- Deployment: Same environment can be replicated in production
Troubleshooting
Virtual environment not activating?
- Ensure Python 3.7+ is installed
- Check file permissions on activation scripts
- Try recreating:
python setup_venv.py
Dependencies not found?
- Activate virtual environment first
- Check if packages are installed:
pip list - Reinstall requirements:
pip install -r requirements.txt
Permission errors on Unix/Linux/Mac?
- Make scripts executable:
chmod +x *.sh - Run with proper permissions