gcp-hockey-results/motm_app
2025-09-29 12:28:47 +08:00
..
static Separate MotM app out 2025-09-29 10:43:48 +08:00
templates Separate MotM app out 2025-09-29 10:43:48 +08:00
.gitignore Update to support py venv 2025-09-29 12:21:58 +08:00
activate_motm.bat Update to support py venv 2025-09-29 12:21:58 +08:00
activate_motm.sh Update to support py venv 2025-09-29 12:21:58 +08:00
app.py Separate MotM app out 2025-09-29 10:43:48 +08:00
app.yaml Separate MotM app out 2025-09-29 10:43:48 +08:00
db_config.py Separate MotM app out 2025-09-29 10:43:48 +08:00
deploy.py Separate MotM app out 2025-09-29 10:43:48 +08:00
forms.py Separate MotM app out 2025-09-29 10:43:48 +08:00
main.py Fix wtforms error 2025-09-29 12:28:47 +08:00
README.md Update to support py venv 2025-09-29 12:21:58 +08:00
readSettings.py Separate MotM app out 2025-09-29 10:43:48 +08:00
requirements.txt Fix wtforms error 2025-09-29 12:28:47 +08:00
run_motm.bat Update to support py venv 2025-09-29 12:21:58 +08:00
run_motm.sh Update to support py venv 2025-09-29 12:21:58 +08:00
SETUP_GUIDE.md Update to support py venv 2025-09-29 12:21:58 +08:00
setup_venv_windows.bat Update to support py venv 2025-09-29 12:21:58 +08:00
setup_venv.ps1 Update to support py venv 2025-09-29 12:21:58 +08:00
setup_venv.py Update to support py venv 2025-09-29 12:21:58 +08:00
tables.py Separate MotM app out 2025-09-29 10:43:48 +08:00
test_app.py Separate MotM app out 2025-09-29 10:43:48 +08:00
VIRTUAL_ENV_GUIDE.md Update to support py venv 2025-09-29 12:21:58 +08:00

HKFC Men's D 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 D 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

Windows Setup:

  1. Create virtual environment:
python -m venv venv

If python doesn't work, try py or use the full path to python.exe

  1. Activate virtual environment:
venv\Scripts\activate.bat
  1. Install dependencies:
pip install --upgrade pip
pip install -r requirements.txt
  1. Run the application:
python main.py

Unix/Linux/Mac Setup:

  1. Create virtual environment:
python3 -m venv venv
  1. Activate virtual environment:
source venv/bin/activate
  1. Install dependencies:
pip install --upgrade pip
pip install -r requirements.txt
  1. Run the application:
python main.py

Convenience Scripts:

  • After setup, you can use activate_motm.bat (Windows) or source activate_motm.sh (Unix)
  • Or use run_motm.bat (Windows) or ./run_motm.sh (Unix) to start directly

Option 2: Manual Virtual Environment Setup

  1. Create virtual environment:
python -m venv venv
  1. Activate virtual environment:

    • Windows: venv\Scripts\activate
    • Unix/Linux/Mac: source venv/bin/activate
  2. Install dependencies:

pip install -r requirements.txt
  1. Configure database settings in db_config.py

  2. Run the application:

python main.py
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure database settings in db_config.py

  2. 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:

  • _hkfcD_matchSquad - Current match squad
  • _HKFC_players - Player database
  • hkfcDAdminSettings - Admin configuration
  • hockeyFixtures - Match fixtures
  • _hkfc_d_motm - MOTM/DotD voting results
  • _motmComments - Match comments
  • _clubTeams - Club and team information
  • mensHockeyClubs - 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

  1. Admin Setup:

    • Access /admin/motm to configure upcoming matches
    • Use /admin/squad to select players for the match
    • Activate voting to generate the public voting URL
  2. Player Voting:

    • Share the generated voting URL with players
    • Players can vote for MOTM and DotD
    • Optional comments can be added
  3. Results:

    • View real-time results at /admin/voting
    • Track season statistics at /admin/poty

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

  1. Activate virtual environment before making changes:

    • Windows: activate_motm.bat or venv\Scripts\activate
    • Unix/Linux/Mac: source activate_motm.sh or source venv/bin/activate
  2. Install new packages:

pip install new-package-name
  1. Update requirements.txt after adding packages:
pip freeze > requirements.txt
  1. 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