-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TECH] Déplacement de la fonctionnalité du kit surveillant dans le do…
- Loading branch information
Showing
34 changed files
with
499 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
api/lib/domain/usecases/get-supervisor-kit-session-info.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
api/src/certification/session/application/invigilator-kit-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { usecases } from '../../shared/domain/usecases/index.js'; | ||
import { tokenService } from '../../../../lib/domain/services/token-service.js'; | ||
import * as requestResponseUtils from '../../../../lib/infrastructure/utils/request-response-utils.js'; | ||
import * as invigilatorKitPdf from '../infrastructure/utils/pdf/invigilator-kit-pdf.js'; | ||
|
||
const getInvigilatorKitPdf = async function ( | ||
request, | ||
h, | ||
dependencies = { tokenService, requestResponseUtils, invigilatorKitPdf }, | ||
) { | ||
const sessionId = request.params.id; | ||
const token = request.query.accessToken; | ||
const userId = dependencies.tokenService.extractUserId(token); | ||
const { lang } = request.query; | ||
const sessionForInvigilatorKit = await usecases.getInvigilatorKitSessionInfo({ sessionId, userId }); | ||
|
||
const { buffer, fileName } = await dependencies.invigilatorKitPdf.getInvigilatorKitPdfBuffer({ | ||
sessionForInvigilatorKit, | ||
lang, | ||
}); | ||
|
||
return h | ||
.response(buffer) | ||
.header('Content-Disposition', `attachment; filename=${fileName}`) | ||
.header('Content-Type', 'application/pdf'); | ||
}; | ||
|
||
const invigilatorKitController = { | ||
getInvigilatorKitPdf, | ||
}; | ||
export { invigilatorKitController }; |
29 changes: 29 additions & 0 deletions
29
api/src/certification/session/application/invigilator-kit-route.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Joi from 'joi'; | ||
import { identifiersType } from '../../../../lib/domain/types/identifiers-type.js'; | ||
import { invigilatorKitController } from './invigilator-kit-controller.js'; | ||
|
||
const register = async function (server) { | ||
server.route([ | ||
{ | ||
method: 'GET', | ||
path: '/api/sessions/{id}/supervisor-kit', | ||
config: { | ||
auth: false, | ||
validate: { | ||
params: Joi.object({ | ||
id: identifiersType.sessionId, | ||
}), | ||
}, | ||
handler: invigilatorKitController.getInvigilatorKitPdf, | ||
tags: ['api', 'sessions', 'invigilator'], | ||
notes: [ | ||
'- **Cette route est restreinte aux utilisateurs appartenant à un centre de certification ayant créé la session**\n' + | ||
'- Cette route permet de télécharger le kit surveillant au format pdf', | ||
], | ||
}, | ||
}, | ||
]); | ||
}; | ||
|
||
const name = 'invigilator-kit-api'; | ||
export { register, name }; |
8 changes: 4 additions & 4 deletions
8
...in/read-models/SessionForSupervisorKit.js → ...n/read-models/SessionForInvigilatorKit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
class SessionForSupervisorKit { | ||
constructor({ id, date, time, address, room, examiner, accessCode, supervisorPassword, version }) { | ||
class SessionForInvigilatorKit { | ||
constructor({ id, date, time, address, room, examiner, accessCode, invigilatorPassword, version }) { | ||
this.id = id; | ||
this.date = date; | ||
this.time = time; | ||
this.address = address; | ||
this.room = room; | ||
this.examiner = examiner; | ||
this.accessCode = accessCode; | ||
this.supervisorPassword = supervisorPassword; | ||
this.invigilatorPassword = invigilatorPassword; | ||
this.version = version; | ||
} | ||
} | ||
|
||
export { SessionForSupervisorKit }; | ||
export { SessionForInvigilatorKit }; |
17 changes: 17 additions & 0 deletions
17
api/src/certification/session/domain/usecases/get-invigilator-kit-session-info.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { UserNotAuthorizedToAccessEntityError } from '../../../../shared/domain/errors.js'; | ||
|
||
const getInvigilatorKitSessionInfo = async function ({ | ||
userId, | ||
sessionId, | ||
sessionRepository, | ||
sessionForInvigilatorKitRepository, | ||
}) { | ||
const hasMembership = await sessionRepository.doesUserHaveCertificationCenterMembershipForSession(userId, sessionId); | ||
if (!hasMembership) { | ||
throw new UserNotAuthorizedToAccessEntityError('User is not allowed to access session.'); | ||
} | ||
|
||
return await sessionForInvigilatorKitRepository.get(sessionId); | ||
}; | ||
|
||
export { getInvigilatorKitSessionInfo }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.