Skip to content
Snippets Groups Projects

Add required trainings for programmes and job offers

Files

@@ -97,6 +97,9 @@ public class JobOfferController {
@Autowired
private ProgramService programService;
@Autowired
private TrainingTypeService trainingTypeService;
@Autowired
private ModelMapper mapper;
@@ -288,6 +291,8 @@ public class JobOfferController {
public String getJobOfferDetails(@PathVariable Long id,
@RequestParam(required = false) String q, Model model) {
JobOfferDetailsDTO offer = jobOfferService.getById(id);
Long programId = courseService.getCourseById(offer.getEdition().getCourse().getId()).getProgram()
.getId();
List<ApplicationDetailsPersonDTO> applications = applicationService
.getFilteredApplicationsForJobOffer(id, q);
@@ -300,7 +305,8 @@ public class JobOfferController {
model.addAttribute("applications", applications.stream()
.sorted(Comparator.comparing(ApplicationSummaryDTO::getCreatedDate)).toList());
model.addAttribute("stats", stats);
model.addAttribute("patchJobOffer", new JobOfferPatchDTO());
model.addAttribute("trainingTypes",
trainingTypeService.getAllTrainingTypesForPrograms(List.of(programId)));
return "job_offer/view_one";
}
@@ -366,6 +372,30 @@ public class JobOfferController {
return "redirect:/job-offer/" + id;
}
/**
* Adds a required training to a job offer.
*
* @param id The id of the job offer
* @param typeId The id of the training
*/
@PostMapping("{id}/required-training/{typeId}")
@PreAuthorize("@authorisationService.isManagerOfJob(#id)")
public @ResponseBody void addRequiredTraining(@PathVariable Long id, @PathVariable Long typeId) {
jobOfferService.addRequiredTraining(id, typeId);
}
/**
* Removes a required training to a job offer.
*
* @param id The id of the job offer
* @param typeId The id of the training type
*/
@DeleteMapping("{id}/required-training/{typeId}")
@PreAuthorize("@authorisationService.isManagerOfJob(#id)")
public @ResponseBody void removeRequiredTraining(@PathVariable Long id, @PathVariable Long typeId) {
jobOfferService.removeRequiredTraining(id, typeId);
}
// endregion
// region import/export
Loading