- Add HTTPSConfig model for managing HTTPS settings - Add admin routes for HTTPS configuration management - Add beautiful admin template for HTTPS configuration - Add database migration for https_config table - Add CLI utility for HTTPS management - Add setup script for automated configuration - Add Caddy configuration generator and manager - Add comprehensive documentation (3 guides) - Add HTTPS Configuration card to admin dashboard - Implement input validation and security features - Add admin-only access control with audit trail - Add real-time configuration preview - Integrate with existing Caddy reverse proxy Features: - Enable/disable HTTPS from web interface - Configure domain, hostname, IP address, port - Automatic SSL certificate management via Let's Encrypt - Real-time Caddyfile generation and reload - Full audit trail with admin username and timestamps - Support for HTTPS and HTTP fallback access points - Beautiful, mobile-responsive UI Modified files: - app/models/__init__.py (added HTTPSConfig import) - app/blueprints/admin.py (added HTTPS routes) - app/templates/admin/admin.html (added HTTPS card) - docker-compose.yml (added Caddyfile mount and admin port) New files: - app/models/https_config.py - app/blueprints/https_config.html - app/utils/caddy_manager.py - https_manager.py - setup_https.sh - migrations/add_https_config_table.py - migrations/add_email_to_https_config.py - HTTPS_STATUS.txt - Documentation files (3 markdown guides)
65 lines
2.3 KiB
Python
Executable File
65 lines
2.3 KiB
Python
Executable File
"""Player feedback model for tracking player status and errors."""
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from app.extensions import db
|
|
|
|
|
|
class PlayerFeedback(db.Model):
|
|
"""Player feedback model for tracking player status updates.
|
|
|
|
Attributes:
|
|
id: Primary key
|
|
player_id: Foreign key to player
|
|
status: Current status (playing, paused, error, unknown)
|
|
current_content_id: ID of currently playing content
|
|
message: Optional status message
|
|
error: Optional error message
|
|
timestamp: Feedback timestamp
|
|
"""
|
|
__tablename__ = 'player_feedback'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
player_id = db.Column(db.Integer, db.ForeignKey('player.id'),
|
|
nullable=False, index=True)
|
|
status = db.Column(db.String(50), nullable=False, default='unknown')
|
|
current_content_id = db.Column(db.Integer, db.ForeignKey('content.id'),
|
|
nullable=True)
|
|
message = db.Column(db.Text, nullable=True)
|
|
error = db.Column(db.Text, nullable=True)
|
|
timestamp = db.Column(db.DateTime, default=datetime.utcnow,
|
|
nullable=False, index=True)
|
|
|
|
# Relationships
|
|
player = db.relationship('Player', back_populates='feedback')
|
|
content = db.relationship('Content', backref='feedback_entries')
|
|
|
|
def __repr__(self) -> str:
|
|
"""String representation of PlayerFeedback."""
|
|
return f'<PlayerFeedback Player={self.player_id} Status={self.status}>'
|
|
|
|
@property
|
|
def is_error(self) -> bool:
|
|
"""Check if feedback indicates an error."""
|
|
return self.status == 'error' or self.error is not None
|
|
|
|
@property
|
|
def age_seconds(self) -> float:
|
|
"""Get age of feedback in seconds."""
|
|
delta = datetime.utcnow() - self.timestamp
|
|
return delta.total_seconds()
|
|
|
|
@classmethod
|
|
def get_latest_for_player(cls, player_id: int) -> Optional['PlayerFeedback']:
|
|
"""Get most recent feedback for a player.
|
|
|
|
Args:
|
|
player_id: Player ID to query
|
|
|
|
Returns:
|
|
Latest PlayerFeedback instance or None
|
|
"""
|
|
return cls.query.filter_by(player_id=player_id)\
|
|
.order_by(cls.timestamp.desc())\
|
|
.first()
|