Backend: Delete BTC školovanje
GitHub Issue: #247
Last modified with commit 7a580a0 on
by Aljaž.
Backend task for deleting a BTC školovanje (DELETE /btc-trainings/{trainingId}) – soft delete, check permissions and the upcoming-only rule, implement, and verify against the spec.
Docs: BTC školovanje list (Actions menu → Ukloni školovanje, Delete confirmation modal)
Spec: DELETE /btc-trainings/{trainingId} (deleteBtcTraining), BtcTrainingConflict in api-docs/openapi.yaml
DB: BtcTrainings (DeletedAt) in api/database/create_schema.sql
1. Double check API spec and DB structure
- Soft delete (decided): the spec soft-deletes (sets
DeletedAt) and keeps candidates, attendance, feedback values and signature files. Data is kept for 2 years (see BTC). Assessments and BTC certificiranje use the same approach. - Rule: only
upcomingcan be deleted → 409training_not_upcoming. Check the docs agree (Aktivni and Prošli can’t be deleted). - After deleting, every BTC školovanje endpoint (detail, edit, attendance, feedback, signature files, download) → 404, and the list excludes it.
- Roles and permissions:
btc-trainings.edit, Trainer only.
2. Implementation
- Roles and permissions: require
btc-trainings.edit→ 403. - DB: set
DeletedAt(andUpdatedAt). Make sure the shared “load školovanje” helper used by the other endpoints filtersDeletedAt IS NULL. - Status check with the shared status helper → 409. Unknown or already deleted id → 404. Success → 204.
3. Verify implementation against spec
- Status codes and the
errorvalue matchdeleteBtcTraining. - Active / past školovanje → 409. Evaluator → 403. Deleting twice → 404 the second time.
- After deleting: list excludes it, detail and signature download → 404.
Done when
A trainer can delete an upcoming školovanje, and it disappears everywhere in the app while its data stays in the database.