Skip to content
Snippets Groups Projects

Deploy fix

2 files
+ 6
12
Compare changes
  • Side-by-side
  • Inline

Files

@@ -17,9 +17,7 @@
@@ -17,9 +17,7 @@
*/
*/
package nl.tudelft.tam.controller;
package nl.tudelft.tam.controller;
import java.io.File;
import java.io.IOException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.Map;
import nl.tudelft.labracore.api.dto.PersonSummaryDTO;
import nl.tudelft.labracore.api.dto.PersonSummaryDTO;
@@ -30,8 +28,8 @@ import nl.tudelft.tam.service.PersonService;
@@ -30,8 +28,8 @@ import nl.tudelft.tam.service.PersonService;
import nl.tudelft.tam.service.TrainingApprovalService;
import nl.tudelft.tam.service.TrainingApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
 
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity;
@@ -120,20 +118,15 @@ public class TrainingApprovalController {
@@ -120,20 +118,15 @@ public class TrainingApprovalController {
@GetMapping("/import/template")
@GetMapping("/import/template")
@PreAuthorize("@authorisationService.isCoordinatorOfAny()")
@PreAuthorize("@authorisationService.isCoordinatorOfAny()")
public ResponseEntity<Resource> downloadTemplateFile() throws IOException, URISyntaxException {
public ResponseEntity<Resource> downloadTemplateFile() {
File file = new File(
Resource resource = new InputStreamResource(
this.getClass()
getClass().getResourceAsStream("/static/import_templates/import_training_template.csv"));
.getResource("/static/import_templates/import_training_template.csv")
.toURI());
UrlResource resource = new UrlResource("file:" + file.getPath());
return ResponseEntity.ok()
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(MediaType.APPLICATION_OCTET_STREAM_VALUE))
.contentType(MediaType.parseMediaType(MediaType.APPLICATION_OCTET_STREAM_VALUE))
.header(HttpHeaders.CONTENT_DISPOSITION,
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + resource.getFilename() + "\"")
"attachment; filename=import_training_template.csv")
.body(resource);
.body(resource);
}
}
@PostMapping("import/{programId}/csv")
@PostMapping("import/{programId}/csv")
Loading