Skip to content
Snippets Groups Projects

Implement approval for TA training

Files

@@ -17,21 +17,21 @@
*/
package nl.tudelft.tam.controller;
import java.time.LocalDate;
import javax.transaction.Transactional;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.labracore.lib.security.user.Person;
import nl.tudelft.tam.dto.create.RaiseRequestCreateDTO;
import nl.tudelft.tam.dto.create.TrainingApprovalRequestCreateDTO;
import nl.tudelft.tam.dto.patch.ShirtPatchDTO;
import nl.tudelft.tam.dto.view.summary.RaiseRequestSummaryDTO;
import nl.tudelft.tam.dto.view.summary.TrainingApprovalRequestSummaryDTO;
import nl.tudelft.tam.model.Profile;
import nl.tudelft.tam.service.ProfileService;
import nl.tudelft.tam.service.RaiseRequestService;
import nl.tudelft.tam.service.TrainingApprovalRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@@ -46,6 +46,9 @@ public class TAMProfileController {
@Autowired
private RaiseRequestService raiseRequestService;
@Autowired
private TrainingApprovalRequestService trainingApprovalRequestService;
/**
* Loads the profile page.
*
@@ -63,8 +66,13 @@ public class TAMProfileController {
RaiseRequestSummaryDTO openRaiseRequest = raiseRequestService.getOpenForPerson(person);
model.addAttribute("openRaiseRequest", openRaiseRequest);
TrainingApprovalRequestSummaryDTO openTrainingApprovalRequest = trainingApprovalRequestService
.getOpenForPerson(person);
model.addAttribute("openTrainingApprovalRequest", openTrainingApprovalRequest);
model.addAttribute("poloPatch", new ShirtPatchDTO());
model.addAttribute("raiseRequestPost", new RaiseRequestCreateDTO());
model.addAttribute("trainingApprovalRequestPost", new TrainingApprovalRequestCreateDTO());
return "profile/view";
}
@@ -85,20 +93,4 @@ public class TAMProfileController {
return "redirect:/profile";
}
/**
* Updates the profile's TA training completion date.
*
* @param person the authenticated person
* @param date the updated date
* @return a redirect to the view page
*/
@Transactional
@PostMapping("training")
public String updateTraining(@AuthenticatedPerson Person person,
@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
profileService.setTrainingPassed(person.getId(), date);
return "redirect:/profile";
}
}
Loading