use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.
the class ErrorRestController method feedbackError.
@PreAuthorize("isAuthenticated()")
@PostMapping("/feedback/error")
public ResponseEntity<Void> feedbackError(@RequestBody Map<String, String> body, HttpSession session) {
logger.info("Entered feedback error...");
String exceptionMessage = body.get("exceptionMessage");
session.setAttribute("feedback", new Feedback(exceptionMessage));
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.
the class HomeController method feedbackSubmit.
@PreAuthorize("isAuthenticated()")
@PostMapping("/feedback")
public String feedbackSubmit(@ModelAttribute Feedback feedback, Model model, RedirectAttributes redirectAttributes) {
logger.info("User has submitted feedback.");
emailService.send(feedback);
// Ensure the feedback form is reset after submission.
model.addAttribute("feedback", new Feedback());
redirectAttributes.addFlashAttribute("success", true);
return "redirect:/feedback";
}
use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.
the class HomeController method feedbackForm.
@PreAuthorize("isAuthenticated()")
@GetMapping("/feedback")
public String feedbackForm(Model model, HttpSession session) {
logger.info("User has entered feedback page.");
Feedback sessionFeedback = (Feedback) session.getAttribute("feedback");
if (sessionFeedback != null) {
sessionFeedback.setType("problem");
sessionFeedback.setEmail(userContextService.getCurrentUid() + "@hawaii.edu");
model.addAttribute("feedback", sessionFeedback);
} else {
Feedback feedback = new Feedback();
feedback.setType("general");
feedback.setEmail(userContextService.getCurrentUid() + "@hawaii.edu");
model.addAttribute("feedback", feedback);
}
return "feedback";
}
use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.
the class HomeControllerTest method requestFeedbackWithException.
@Test
@WithMockUhUser
public void requestFeedbackWithException() throws Exception {
HttpSession session = mockMvc.perform(get("/feedback").sessionAttr("feedback", new Feedback("exception"))).andExpect(status().isOk()).andExpect(model().attributeExists("feedback")).andExpect(model().attribute("feedback", hasProperty("exceptionMessage", equalTo("exception")))).andExpect(model().attribute("feedback", hasProperty("email", equalTo("user@hawaii.edu")))).andReturn().getRequest().getSession();
assertThat(session.getAttribute("feedback"), notNullValue());
}
use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.
the class EmailServiceTest method createBaseFeedback.
private Feedback createBaseFeedback() {
Feedback feedback = new Feedback();
feedback.setName("John Doe");
feedback.setEmail("jdoe@hawaii.edu");
feedback.setType("problem");
feedback.setMessage("Some problem happened.");
feedback.setExceptionMessage("");
return feedback;
}
Aggregations