Backend: - Created routers/clubs.py with full CRUD - Clubs: list, get, create, update, delete (admin only) - Divisions: list, create, update, delete (admin only) - Training Groups: list, get, create, update, delete (admin/trainer) - Registered clubs router in main.py - Permission checks: admin for clubs/divisions, trainer for groups Frontend: - Complete ClubsPage with 3 tabs (Vereine, Sparten, Gruppen) - Role-based UI (admin sees all actions, trainer can manage groups) - Full CRUD forms with modals - Mobile-responsive card layouts - Updated api.js with all club/division/group functions Migration already exists: 002_organization.sql (clubs, divisions, training_groups) Next: Skills & Methods display (read-only)
93 lines
2.3 KiB
Python
93 lines
2.3 KiB
Python
"""
|
|
Shinkan Jinkendo - Main Application Entry Point
|
|
|
|
Trainer- und Vereinsplattform für Kampfsport-Trainingsplanung
|
|
"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
import os
|
|
|
|
from version import APP_VERSION, BUILD_DATE, DB_SCHEMA_VERSION, MODULE_VERSIONS
|
|
|
|
# Run database migrations on startup
|
|
try:
|
|
import run_migrations
|
|
run_migrations.main()
|
|
print("✓ Database migrations completed")
|
|
except Exception as e:
|
|
print(f"⚠ Warning: Migration error: {e}")
|
|
print(" Continuing startup - migrations may need manual intervention")
|
|
|
|
# Initialize FastAPI app
|
|
app = FastAPI(
|
|
title="Shinkan Jinkendo API",
|
|
description="Trainer- und Vereinsplattform für Kampfsport-Trainingsplanung",
|
|
version=APP_VERSION
|
|
)
|
|
|
|
# CORS Configuration
|
|
ALLOWED_ORIGINS = os.getenv("ALLOWED_ORIGINS", "http://localhost:3098").split(",")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=ALLOWED_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# TODO: Initialize Database with migrations
|
|
|
|
# Version Endpoint (public, no auth)
|
|
@app.get("/api/version")
|
|
def get_version():
|
|
"""Get application version and build info"""
|
|
return {
|
|
"app_version": APP_VERSION,
|
|
"build_date": BUILD_DATE,
|
|
"backend_version": APP_VERSION,
|
|
"modules": MODULE_VERSIONS,
|
|
"db_schema_version": DB_SCHEMA_VERSION,
|
|
"environment": os.getenv("ENVIRONMENT", "development")
|
|
}
|
|
|
|
# Health Check
|
|
@app.get("/health")
|
|
def health_check():
|
|
"""Health check endpoint"""
|
|
return {"status": "healthy", "version": APP_VERSION}
|
|
|
|
# Root Endpoint
|
|
@app.get("/")
|
|
def read_root():
|
|
"""Root endpoint - API info"""
|
|
return {
|
|
"app": "Shinkan Jinkendo API",
|
|
"version": APP_VERSION,
|
|
"docs": "/docs",
|
|
"health": "/health"
|
|
}
|
|
|
|
# Register routers
|
|
from routers import auth, profiles, exercises, clubs
|
|
|
|
app.include_router(auth.router)
|
|
app.include_router(profiles.router)
|
|
app.include_router(exercises.router)
|
|
app.include_router(clubs.router)
|
|
|
|
# TODO: Add more routers as they are created
|
|
# from routers import skills, methods
|
|
# app.include_router(skills.router, prefix="/api")
|
|
# ... etc
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(
|
|
"main:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=True
|
|
)
|