Skip to content
Snippets Groups Projects

Improve offer position to specific person feature

Files

@@ -18,9 +18,7 @@
package nl.tudelft.tam.controller;
import java.io.IOException;
import java.util.List;
import nl.tudelft.labracore.api.dto.PersonSummaryDTO;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.labracore.lib.security.user.Person;
import nl.tudelft.tam.service.ApplicationService;
@@ -35,7 +33,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
@RequestMapping("application")
@@ -177,44 +174,6 @@ public class ApplicationController {
return "redirect:/application/my" + (q != null ? "?q=" + q : "");
}
/**
* Send a job offer to a specific person
*
* @param offerId The job for which to send the offer
* @param username The username of the person (if chosen option)
* @param studentNumber The student number of the person (if chosen option)
* @param studentName The name of the person (if chosen option)
* @param redirectAttrs The model attributes to keep when redirecting
* @return A redirect to the specific job offer page
*/
@PostMapping("new-offer/{offerId}")
@PreAuthorize("@authorisationService.isManagerOfAny()")
public String sendNewOffer(@PathVariable Long offerId,
@RequestParam(required = false) String username,
@RequestParam(required = false) Long studentNumber,
@RequestParam(required = false) String studentName,
RedirectAttributes redirectAttrs) {
boolean error = false;
if (username != null && !username.isEmpty()) {
error = !applicationService.offerByUsername(username, offerId);
} else if (studentNumber != null) {
error = !applicationService.offerByStudentNumber(studentNumber, offerId);
} else if (studentName != null && !studentName.isEmpty()) {
try {
List<PersonSummaryDTO> possibleStudents = personService
.searchPeopleByDisplayNameContaining(studentName);
redirectAttrs.addFlashAttribute("specificOfferStudents", possibleStudents);
} catch (Exception e) {
error = true;
}
} else {
error = true;
}
redirectAttrs.addFlashAttribute("specificOfferError", error);
return "redirect:/job-offer/" + offerId;
}
// endregion
/**
Loading