Skip to content
Snippets Groups Projects
Commit 4600505f authored by michael.minelli's avatar michael.minelli
Browse files

Merge branch 'bug-fix-correction-visibility' into v3.5.2

parents a3fd9f3e e1e2aeed
No related branches found
No related tags found
No related merge requests found
Pipeline #29764 passed
...@@ -61,8 +61,8 @@ class AssignmentRoutes implements RoutesManager { ...@@ -61,8 +61,8 @@ class AssignmentRoutes implements RoutesManager {
backend.patch('/assignments/:assignmentNameOrUrl/publish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.changeAssignmentPublishedStatus(true).bind(this)); backend.patch('/assignments/:assignmentNameOrUrl/publish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.changeAssignmentPublishedStatus(true).bind(this));
backend.patch('/assignments/:assignmentNameOrUrl/unpublish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.changeAssignmentPublishedStatus(false).bind(this)); backend.patch('/assignments/:assignmentNameOrUrl/unpublish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.changeAssignmentPublishedStatus(false).bind(this));
backend.post('/assignments/:assignmentNameOrUrl/corrections', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), ParamsValidatorMiddleware.validate(this.assignmentAddCorrigeValidator), this.addUpdateAssignmentCorrection(false).bind(this)); backend.post('/assignments/:assignmentNameOrUrl/corrections', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), ParamsValidatorMiddleware.validate(this.assignmentAddCorrigeValidator), this.linkUpdateAssignmentCorrection(false).bind(this));
backend.patch('/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.addUpdateAssignmentCorrection(true).bind(this)); backend.patch('/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.linkUpdateAssignmentCorrection(true).bind(this));
} }
// Get an assignment by its name or gitlab url // Get an assignment by its name or gitlab url
...@@ -203,7 +203,7 @@ class AssignmentRoutes implements RoutesManager { ...@@ -203,7 +203,7 @@ class AssignmentRoutes implements RoutesManager {
}; };
} }
private addUpdateAssignmentCorrection(isUpdate: boolean): (req: express.Request, res: express.Response) => Promise<void> { private linkUpdateAssignmentCorrection(isUpdate: boolean): (req: express.Request, res: express.Response) => Promise<void> {
return async (req: express.Request, res: express.Response): Promise<void> => { return async (req: express.Request, res: express.Response): Promise<void> => {
if ( req.boundParams.exercise?.assignmentName != req.boundParams.assignment?.name ) { if ( req.boundParams.exercise?.assignmentName != req.boundParams.assignment?.name ) {
return req.session.sendResponse(res, StatusCodes.BAD_REQUEST, undefined, 'The exercise does not belong to the assignment', DojoStatusCode.ASSIGNMENT_EXERCISE_NOT_RELATED); return req.session.sendResponse(res, StatusCodes.BAD_REQUEST, undefined, 'The exercise does not belong to the assignment', DojoStatusCode.ASSIGNMENT_EXERCISE_NOT_RELATED);
...@@ -221,6 +221,10 @@ class AssignmentRoutes implements RoutesManager { ...@@ -221,6 +221,10 @@ class AssignmentRoutes implements RoutesManager {
const lastCommit = await GitlabManager.getRepositoryLastCommit(req.boundParams.exercise!.gitlabId); const lastCommit = await GitlabManager.getRepositoryLastCommit(req.boundParams.exercise!.gitlabId);
if ( lastCommit ) { if ( lastCommit ) {
if ( !isUpdate ) {
await GitlabManager.changeRepositoryVisibility(req.boundParams.assignment.gitlabId, GitlabVisibility.INTERNAL);
}
await db.exercise.update({ await db.exercise.update({
where: { where: {
id: req.boundParams.exercise!.id id: req.boundParams.exercise!.id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment