Skip to content
Snippets Groups Projects

If students are in group, they can no longer enqueue again

Files

@@ -168,7 +168,7 @@ public class LabController {
*/
@GetMapping("/lab/{qSession}")
@PreAuthorize("@permissionService.canViewSession(#qSession)")
public String getSessionView(@PathEntity QueueSession<?> qSession,
public <R extends Request<?>> String getSessionView(@PathEntity QueueSession<R> qSession,
@AuthenticatedPerson Person person,
Model model) {
setEnqueuePageAttributes(qSession, model, person);
@@ -183,8 +183,11 @@ public class LabController {
} else {
requests = qSession.getRequests();
}
//if the person should see only their own requests, they see their reqiests and their group requests
if (!ps.canViewSessionRequests(qSession.getId())) {
requests = requests.stream().filter(r -> Objects.equals(r.getRequester(), person.getId()))
requests = requests.stream().filter(r -> (Objects.equals(r.getRequester(), person.getId()) ||
rs.getOpenRequestForGroupOfPerson(qSession.getId(), person.getId(), qSession)
.map(groupRequest -> Objects.equals(groupRequest, r)).orElse(false)))
.toList();
}
model.addAttribute("requests",
@@ -194,9 +197,11 @@ public class LabController {
.collect(Collectors.toList()));
// Check whether there is an open request for the authenticated user and add it to the model
Optional<?> currOptRequest = qSession.getOpenRequestForPerson(person.getId());
Optional<R> currOptRequest = qSession.getOpenRequestForPerson(person.getId())
.or(() -> rs.getOpenRequestForGroupOfPerson(qSession.getId(), person.getId(), qSession));
if (currOptRequest.isPresent()) {
Request<?> currRequest = (Request<?>) currOptRequest.get();
Request<?> currRequest = currOptRequest.get();
// If the user is currently being processed it should be looking at the request page
if (currRequest.getEventInfo().getStatus().isProcessing()) {
return "redirect:/request/" + currRequest.getId();
Loading