Backend: - Created migration 006_training_planning.sql - training_units table (planned vs actual, status, notes) - training_unit_exercises M:N (order, duration, modifications) - Created routers/training_planning.py with full CRUD - List with filters (group, date range, status) - Get detail with exercises - Create/Update/Delete with access control - Quick create endpoint (auto-fills from group defaults) - Permission: trainer for own groups, admin for all - Registered training_planning router in main.py Frontend: - Complete TrainingPlanningPage with full planning workflow - Group selector + date range picker - List view with status badges (planned/completed/cancelled) - Create/Edit modal with exercise management - Drag to reorder exercises (▲▼) - Quick create button (one-click with group defaults) - Durchführung section (actual date/time, attendance, status) - Public notes + trainer-only notes - Updated api.js with deleteTrainingUnit and quickCreateTrainingUnit - Added /planning route to App.jsx - Navigation already configured (Calendar icon) This is the CORE feature - trainers can now plan and document training sessions. Next: Admin routes, role system refinement, testing
61 lines
1.9 KiB
SQL
61 lines
1.9 KiB
SQL
-- Migration 006: Training Planning (Training Units)
|
|
-- Erstellt: 2026-04-22
|
|
-- Beschreibung: Trainingsplanung und -dokumentation
|
|
|
|
-- Training Units (Trainingseinheiten)
|
|
CREATE TABLE training_units (
|
|
id SERIAL PRIMARY KEY,
|
|
group_id INT REFERENCES training_groups(id) ON DELETE CASCADE,
|
|
|
|
-- Planung
|
|
planned_date DATE NOT NULL,
|
|
planned_time_start TIME,
|
|
planned_time_end TIME,
|
|
planned_focus VARCHAR(200),
|
|
|
|
-- Durchführung
|
|
actual_date DATE,
|
|
actual_time_start TIME,
|
|
actual_time_end TIME,
|
|
attendance_count INT,
|
|
|
|
-- Status & Notizen
|
|
status VARCHAR(50) DEFAULT 'planned', -- planned, completed, cancelled
|
|
notes TEXT,
|
|
trainer_notes TEXT,
|
|
|
|
-- Meta
|
|
created_by INT REFERENCES profiles(id),
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
updated_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_training_units_group ON training_units(group_id);
|
|
CREATE INDEX idx_training_units_date ON training_units(planned_date);
|
|
CREATE INDEX idx_training_units_status ON training_units(status);
|
|
CREATE INDEX idx_training_units_created_by ON training_units(created_by);
|
|
|
|
-- Training Unit Exercises (M:N - geplante und durchgeführte Übungen)
|
|
CREATE TABLE training_unit_exercises (
|
|
id SERIAL PRIMARY KEY,
|
|
training_unit_id INT REFERENCES training_units(id) ON DELETE CASCADE,
|
|
exercise_id INT REFERENCES exercises(id),
|
|
|
|
-- Reihenfolge
|
|
order_index INT NOT NULL,
|
|
|
|
-- Zeitplanung
|
|
planned_duration_min INT,
|
|
actual_duration_min INT,
|
|
|
|
-- Notizen
|
|
notes TEXT,
|
|
modifications TEXT, -- Anpassungen während der Durchführung
|
|
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_training_unit_exercises_unit ON training_unit_exercises(training_unit_id);
|
|
CREATE INDEX idx_training_unit_exercises_exercise ON training_unit_exercises(exercise_id);
|
|
CREATE INDEX idx_training_unit_exercises_order ON training_unit_exercises(training_unit_id, order_index);
|