Backend: BTC certificiranje detail
Last modified with commit 374306c on
by Aljaž.
Backend task for the BTC certificiranje detail page (GET /btc-certifications/{certificationId}) – check the header, komisija, candidates and the caller's Usmeni ispit status against the API spec and DB structure, permissions, implement, and verify against the spec.
Docs: BTC certificiranje detail
Spec: GET /btc-certifications/{certificationId} (getBtcCertificationDetail), BtcCertificationDetail in api-docs/openapi.yaml
DB: BtcCertifications, BtcCertificationCandidates, BtcCertificationBoardMembers, BtcCertificationGrades in api/database/create_schema.sql
The detail endpoint is also used by the edit form and for the header / candidate name on the Usmeni ispit form.
1. Double check API spec and DB structure
- Header: name, status, brand, date, “Komisija:” list →
name,status,brandCode,startDate/endDate,boardMembers(active only). The docs recommend showing the date range; the response has both dates. - Candidates: name, e-mail, partner →
fullName,email,partnerId. The partner name comes from the partner lookup. Check the frontend can resolve it (or addpartnerName). - Usmeni ispit row: the caller’s status →
myOralExamCompleted; “Otvori” only for komisija members →isBoardMember. Both use active membership: a removed member sees no “Otvori”. Confirm. - “UREDI CERTIFICIRANJE” is shown for Aktivni / Nadolazeći and only to users with
btc-certifications.edit(Trainer; hidden from BTC evaluators, per the docs). The frontend decides this fromstatusandGET /me/permissions. -
hasGradesper candidate (any member’s grade, removed members included, or a written exam score) is used by the edit form to hide “–”. - Komisija members can keep editing after Zaključeno and in any certificiranje status. Nothing here blocks that.
- Roles and permissions:
btc-certifications.access(Trainer, BTC evaluator), all certificiranja. - DB: removed members (
DeletedAtnot null) are left out ofboardMembers.
2. Implementation
- Roles and permissions: require
btc-certifications.access→ 403. - DB: load the certificiranje (not deleted, else 404), active members, candidates, and the
caller’s grades for all candidates (one query), plus a “has grades” flag per candidate (one
query with
EXISTS). -
isBoardMember: the caller’s user id matches an active BtcCertificationBoardMembers row. -
myOralExamCompleted: use the shared Zaključeno helper from Backend: Form – Modul 5 – Usmeni ispit (grade a + all 7 categories).nullwhenisBoardMemberis false.
3. Verify implementation against spec
- Shape and status codes match
getBtcCertificationDetail. - Komisija member:
isBoardMembertrue, status per candidate correct after saving a full and a partial form. - Trainer not in komisija:
isBoardMemberfalse,myOralExamCompletednull. - Removed member: not in
boardMembers,isBoardMemberfalse, their grades still makehasGradestrue. - Unknown / deleted id → 404. User without access → 403.
Done when
The detail page shows the header, komisija and candidates, with the caller’s own Usmeni ispit status and “Otvori” for komisija members only.