Backend: Delete BTC certificiranje
GitHub Issue: #254
Last modified with commit 7a580a0 on
by Aljaž.
Backend task for deleting a BTC certificiranje (DELETE /btc-certifications/{certificationId}) – soft delete, check permissions and the upcoming-only rule, implement, and verify against the spec.
Docs: BTC certificiranje list (Actions menu → Ukloni certificiranje, Delete confirmation modal)
Spec: DELETE /btc-certifications/{certificationId} (deleteBtcCertification), BtcCertificationConflict in api-docs/openapi.yaml
DB: BtcCertifications (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, komisija and grades. Data is kept for 2 years (see BTC), the same as Backend: Delete BTC školovanje and Assessments. - Rule: only
upcomingcan be deleted → 409certification_not_upcoming. Check the docs agree (Aktivni and Prošli can’t be deleted). - After deleting, every BTC certificiranje endpoint (detail, edit, oral exam form, results, written exam scores) → 404, and the list excludes it.
- Roles and permissions:
btc-certifications.edit, Trainer only (BTC evaluators can’t delete; see Roles).
2. Implementation
- Roles and permissions: require
btc-certifications.edit→ 403. - DB: set
DeletedAt(andUpdatedAt). Make sure the shared “load certificiranje” 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 matchdeleteBtcCertification. - Active / past certificiranje → 409. BTC evaluator → 403. Deleting twice → 404 the second time.
- After deleting: list excludes it; detail, oral exam form and results → 404.
Done when
A trainer can delete an upcoming certificiranje, and it disappears everywhere in the app while its data stays in the database.