Skip to content
Snippets Groups Projects

Resolve "Add programme selection to job offers and extra work pages"

Files

@@ -19,7 +19,9 @@ package nl.tudelft.tam.controller;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import nl.tudelft.labracore.api.dto.ProgramDetailsDTO;
@@ -125,9 +127,10 @@ public class ApplicationController {
*/
@PostMapping("submit/{id}")
public String submitApplication(@AuthenticatedPerson Person person, @PathVariable Long id,
@RequestParam(required = false) String page) {
@RequestParam(required = false) String page, @RequestParam(required = false) Long program) {
applicationService.submit(person.getId(), id);
return "redirect:/" + (page != null ? page : "job-offer/open");
return "redirect:/"
+ (page != null ? page : "job-offer/open" + (program == null ? "" : "?program=" + program));
}
/**
@@ -142,10 +145,21 @@ public class ApplicationController {
public String retractApplication(@AuthenticatedPerson Person person, @PathVariable Long id,
@RequestParam(required = false) String page,
@RequestParam(required = false) String q,
@RequestParam(required = false) String tab) {
@RequestParam(required = false) String tab,
@RequestParam(required = false) String program) {
applicationService.retract(person.getId(), id);
return "redirect:/" + (page != null ? page : "job-offer/open") + (q != null ? "?q=" + q : "")
+ (tab != null ? "&tab=" + tab : "");
String url = page == null ? "job-offer/open" : page;
Map<String, String> params = new HashMap<>();
if (q != null)
params.put("q", q);
if (tab != null)
params.put("tab", tab);
if (program != null)
params.put("program", program);
return "redirect:/" + url + getURLParamsString(params);
}
/**
@@ -218,9 +232,29 @@ public class ApplicationController {
@PreAuthorize("@authorisationService.offerExistsFor(#id)")
public String acceptApplication(@AuthenticatedPerson Person person, @PathVariable Long id,
@RequestParam(required = false) String q,
@RequestParam(required = false) String tab) {
@RequestParam(required = false) String tab,
@RequestParam(required = false) String program) {
applicationService.accept(person.getId(), id);
return "redirect:/job-offer/open" + (q != null ? "?q=" + q : "") + (tab != null ? "&tab=" + tab : "");
Map<String, String> params = new HashMap<>();
if (q != null)
params.put("q", q);
if (tab != null)
params.put("tab", tab);
if (program != null)
params.put("program", program);
return "redirect:/job-offer/open" + getURLParamsString(params);
}
private static String getURLParamsString(Map<String, String> params) {
StringBuilder result = new StringBuilder();
char sep = '?';
for (String param : params.keySet()) {
result.append(sep).append(param).append("=").append(params.get(param));
sep = '&';
}
return result.toString();
}
// endregion
Loading