227 lines
5.9 KiB
Markdown
227 lines
5.9 KiB
Markdown
# 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
|
|
|
|
### Option 1: Using Virtual Environment (Recommended)
|
|
|
|
**Windows Setup:**
|
|
|
|
1. **Create virtual environment**:
|
|
```cmd
|
|
python -m venv venv
|
|
```
|
|
*If `python` doesn't work, try `py` or use the full path to python.exe*
|
|
|
|
2. **Activate virtual environment**:
|
|
```cmd
|
|
venv\Scripts\activate.bat
|
|
```
|
|
|
|
3. **Install dependencies**:
|
|
```cmd
|
|
pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
4. **Run the application**:
|
|
```cmd
|
|
python main.py
|
|
```
|
|
|
|
**Unix/Linux/Mac Setup:**
|
|
|
|
1. **Create virtual environment**:
|
|
```bash
|
|
python3 -m venv venv
|
|
```
|
|
|
|
2. **Activate virtual environment**:
|
|
```bash
|
|
source venv/bin/activate
|
|
```
|
|
|
|
3. **Install dependencies**:
|
|
```bash
|
|
pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
4. **Run the application**:
|
|
```bash
|
|
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**:
|
|
```bash
|
|
python -m venv venv
|
|
```
|
|
|
|
2. **Activate virtual environment**:
|
|
- **Windows**: `venv\Scripts\activate`
|
|
- **Unix/Linux/Mac**: `source venv/bin/activate`
|
|
|
|
3. **Install dependencies**:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
4. **Configure database settings** in `db_config.py`
|
|
|
|
5. **Run the application**:
|
|
```bash
|
|
python main.py
|
|
```
|
|
|
|
### Option 3: Global Installation (Not Recommended)
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Configure database settings in `db_config.py`
|
|
|
|
3. Run the application:
|
|
```bash
|
|
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**:
|
|
```bash
|
|
pip install new-package-name
|
|
```
|
|
|
|
3. **Update requirements.txt** after adding packages:
|
|
```bash
|
|
pip freeze > requirements.txt
|
|
```
|
|
|
|
4. **Deactivate** when done:
|
|
```bash
|
|
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
|