Skip to content
Snippets Groups Projects
Commit 05f9b6fa authored by Henry Page's avatar Henry Page :speech_balloon:
Browse files

implement Ruben suggestions

parent 838e2462
Branches
Tags
2 merge requests!630New release,!628Resolve "Course filter approved requests broken"
......@@ -330,7 +330,7 @@ public class PermissionService {
* @return Whether the currently authenticated person has a staff role in any of the given
* course editions.
*/
private boolean hasStaffRole(List<Long> editionIds) {
public boolean hasStaffRole(List<Long> editionIds) {
return withAnyRole(editionIds, (person, role) -> STAFF_ROLES.contains(role));
}
......
......@@ -52,7 +52,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.ListUtils;
import reactor.core.publisher.Mono;
......@@ -107,6 +106,9 @@ public class RequestService {
@Lazy
private LabService lService;
@Autowired
private PermissionService permissionService;
private static final ReentrantLock lock = new ReentrantLock();
/**
......@@ -525,7 +527,7 @@ public class RequestService {
*/
public List<LabRequest> filterRequestsSharedEditionCheck(List<LabRequest> requests, Person person) {
// Check to make sure requests are not empty, otherwise API call fails.
if (ListUtils.isEmpty(requests)) {
if (requests.isEmpty()) {
return requests;
}
......@@ -533,8 +535,8 @@ public class RequestService {
var allowedAssignments = Objects
.requireNonNull(asApi.getAssignmentsWithModules(assignmentIds).collectList().block()).stream()
.filter(assignment -> roleDTOService.hasStaffPermission(assignment.getModule().getEdition(),
person))
.filter(assignment -> permissionService
.hasStaffRole(List.of(assignment.getModule().getEdition().getId())))
.map(AssignmentModuleDetailsDTO::getId)
.collect(Collectors.toSet());
......
......@@ -149,8 +149,4 @@ public class RoleDTOService {
|| type.equals(RoleDetailsDTO.TypeEnum.TEACHER)
|| type.equals(RoleDetailsDTO.TypeEnum.TEACHER_RO);
}
public boolean hasStaffPermission(EditionSummaryDTO eDto, Person person) {
return rolesForPersonInEdition(eDto, person).stream().anyMatch(this::isStaff);
}
}
......@@ -54,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.test.context.support.WithUserDetails;
import org.springframework.test.annotation.DirtiesContext;
import reactor.core.publisher.Flux;
......@@ -349,6 +350,7 @@ public class RequestServiceTest {
}
@Test
@WithUserDetails("student200")
void oopTaGetsOopRequestsOnlyInSharedSession() {
Person p1 = new Person();
p1.setId(oopNowTAs[0].getPerson().getId());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment