Skip to content
Snippets Groups Projects

Add Import Templates + Add Checkbox for Non-Default Baan Codes + Include Training in Coordinator Exports

Files

@@ -17,7 +17,9 @@
*/
package nl.tudelft.tam.controller;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@@ -38,7 +40,10 @@ import nl.tudelft.tam.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
@@ -255,6 +260,22 @@ public class ExtraWorkController {
return "redirect:/job-offer/manage";
}
@GetMapping("/import/template")
@PreAuthorize("@authorisationService.isCoordinatorOfAny()")
public ResponseEntity<Resource> downloadTemplateFile() throws IOException, URISyntaxException {
File file = new File(
this.getClass()
.getResource("/static/import_templates/import_extra_work_template.csv")
.toURI());
UrlResource resource = new UrlResource("file:" + file.getPath());
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(MediaType.APPLICATION_OCTET_STREAM_VALUE))
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + resource.getFilename() + "\"")
.body(resource);
}
// endregion
}
Loading