- Introduced application-wide constants for file uploads, image processing, pagination, and authentication in `constants.py`. - Implemented synchronous and asynchronous board ownership verification functions in `ownership.py`. - Created a base repository class with common CRUD operations in `repository.py`. - Added standard response utilities for error and success messages in `responses.py`. - Refactored image validation to utilize constants for file size and MIME types. - Enhanced frontend components with consistent styling and validation utilities for forms. - Established global styles for buttons, forms, loading indicators, and messages to ensure a cohesive UI experience.
39 lines
894 B
Python
39 lines
894 B
Python
"""Application-wide constants."""
|
|
|
|
# File upload limits
|
|
MAX_IMAGE_SIZE = 52_428_800 # 50MB in bytes
|
|
MAX_ZIP_SIZE = 209_715_200 # 200MB in bytes
|
|
|
|
# Image processing
|
|
MAX_IMAGE_DIMENSION = 10_000 # Max width or height in pixels
|
|
THUMBNAIL_SIZES = {
|
|
"low": 800, # For slow connections (<1 Mbps)
|
|
"medium": 1600, # For medium connections (1-5 Mbps)
|
|
"high": 3200, # For fast connections (>5 Mbps)
|
|
}
|
|
|
|
# Pagination defaults
|
|
DEFAULT_PAGE_SIZE = 50
|
|
MAX_PAGE_SIZE = 100
|
|
|
|
# Board limits
|
|
MAX_BOARD_TITLE_LENGTH = 255
|
|
MAX_BOARD_DESCRIPTION_LENGTH = 1000
|
|
MAX_IMAGES_PER_BOARD = 1000
|
|
|
|
# Authentication
|
|
TOKEN_EXPIRE_HOURS = 168 # 7 days
|
|
PASSWORD_MIN_LENGTH = 8
|
|
|
|
# Supported image formats
|
|
ALLOWED_MIME_TYPES = {
|
|
"image/jpeg",
|
|
"image/jpg",
|
|
"image/png",
|
|
"image/gif",
|
|
"image/webp",
|
|
"image/svg+xml",
|
|
}
|
|
|
|
ALLOWED_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"}
|