Files
digiserver-v2/app/models/content.py
Quality App Developer 48f1bfbcad Add HTTPS configuration management system
- 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)
2026-01-14 12:02:49 +02:00

64 lines
2.3 KiB
Python
Executable File

"""Content model for media files."""
from datetime import datetime
from typing import Optional, List
from app.extensions import db
class Content(db.Model):
"""Content model representing media files for display.
Attributes:
id: Primary key
filename: Original filename
content_type: Type of content (image, video, pdf, presentation, other)
duration: Default display duration in seconds
file_size: File size in bytes
description: Optional content description
uploaded_at: Upload timestamp
"""
__tablename__ = 'content'
id = db.Column(db.Integer, primary_key=True)
filename = db.Column(db.String(255), nullable=False, unique=True, index=True)
content_type = db.Column(db.String(50), nullable=False, index=True)
duration = db.Column(db.Integer, default=10, nullable=True)
file_size = db.Column(db.BigInteger, nullable=True)
description = db.Column(db.Text, nullable=True)
uploaded_at = db.Column(db.DateTime, default=datetime.utcnow,
nullable=False, index=True)
# Relationships - many-to-many with playlists
playlists = db.relationship('Playlist', secondary='playlist_content',
back_populates='contents', lazy='dynamic')
groups = db.relationship('Group', secondary='group_content',
back_populates='contents', lazy='dynamic')
def __repr__(self) -> str:
"""String representation of Content."""
return f'<Content {self.filename} (Type={self.content_type})>'
@property
def file_size_mb(self) -> float:
"""Get file size in megabytes."""
if self.file_size:
return round(self.file_size / (1024 * 1024), 2)
return 0.0
@property
def group_count(self) -> int:
"""Get number of groups containing this content."""
return self.groups.count()
def is_image(self) -> bool:
"""Check if content is an image."""
return self.content_type == 'image'
def is_video(self) -> bool:
"""Check if content is a video."""
return self.content_type == 'video'
def is_pdf(self) -> bool:
"""Check if content is a PDF."""
return self.content_type == 'pdf'