Skip to content
Snippets Groups Projects

Add is teacher in any active edition endpoint

2 files
+ 29
0
Compare changes
  • Side-by-side
  • Inline

Files

@@ -265,4 +265,17 @@ public class AuthorizationController {
clusterRepository.findByIdOrThrow(clusterId).getCohort().getProgram());
}
/**
* Checks whether the given person has any teacher (non-read-only) role within any of the currently active
* editions.
*
* @param person The Person to check credentials for.
* @return Whether the given person has the requested permission.
*/
@GetMapping("/{person}/teacher-in-any-current-edition")
public boolean hasTeacherRoleInAnyCurrentEdition(@PathEntity Person person) {
return person.getRoles().stream().anyMatch(r -> r.getType().equals(TEACHER) &&
r.getEdition().isActive());
}
}
Loading